Refactoring Code Under My Own Initiative?

I've made a significant amount of progress if anyone wants to take a look. No, it isn't quite working, yet, but it's almost there! The files I've been working on are here:


One particular difficulty is that the two outward-facing functions from theme.ts are extremely loosely typed. I am trying to limit my work for the time being to the contents of the above-linked folder (other than theme.ts), and the relative lack of typing makes the two functions harder to reimplement and subsequently debug.

Like, for example, most variables that get passed to themeStyle() are type string, but not quite all. and most of the values returned are individual CSS attributes, but there are a handful of bundled JavaScript Objects thrown in just to keep things fun.

The currently breaking behavior is calling StyleProvider.get('globalStyle'), which seems like it should work, but it doesn't. Again, all of the build scripts run without error (though with plenty of dependency warnings), and my changes to the code passed the commit preflight, so... fun!

Ideally once I get this working I would like to replace the themeStyle() calls with enum values so that all values passed to it will be valid, as the constructor for StyleProvider iterates through the name enums and initializes them.

Another thought I have is that replacing all of the cached styles with actual objects from npm/css should further reduce the possibility of errors. Doing so would also help with converting the various themes from TypeScript classes to CSS and/or Sass, which would further the ultimate goal of making the theme system fully extensible for end users.

Probably the biggest reason I've avoided replacing all of the calls to themeStyle() is that I want to avoid integration collisions from modifying literally dozens of TypeScript files all over the application. That, and having to dig through the call stack to figure out what is being passed in each of those dozens of instances. I mean, ultimately this will be necessary; I would just like to get the reimplementation of the existing functions working first.