loading...

re: My confusions about TypeScript VIEW POST

TOP OF THREAD FULL DISCUSSION
re: 1) function handleRelations<T extends Model>(modelClass: T) { Look up Generics Constraints in the typescript manual. 2) That's not a Ty...
 

You beat me to it! typeof Model and T extends Model are the useful features here, but I also agree with Edward Tam - you should probably eschew subclassing in general. "Is a" object relationships are the tightest form of coupling that exists. Instead use functions or even mixins, if you must attach "methods" to your objects. You probably don't need a base class when you have interfaces and mixins available to you.

 

is a is strong, but can be loosened with Factories and Bridge Pattern

Haven't found a good use for the Bridge Pattern, but I've often wondered why more ORMs aren't using Factories/mixins

code of conduct - report abuse