Alternative to TypeScript Classes
Currently, I'm refactoring TypeScript code into classes because I want to use extends for N features to inherit some base functionality.
Previously, I had pockets of functions organized in separate files based on the type of functionality that they were providing. (foo.ts, bar.ts, baz.ts)
I figured classes would be better to stay DRY, as it removes a lot of copy-paste boilerplate between every feature. (common variables + common functions)
But I'm finding it really difficult to transition this structure into classes, because there are shared variables in a feature directory (
variables.ts
), and there is no partial
keyword in TypeScript like there is in C#, so I have to stick thousands of lines of code in the same file (to avoid circular imports).
As a result, I'm brainstorming ideas about how I could use normal objects to emulate classes, but it seems very messy.
Are there any blogs that describe some patterns that might be useful here?1 Reply
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View