DEV Community

Discussion on: My confusions about TypeScript

Collapse
 
jdforsythe profile image
Jeremy Forsythe

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.

Collapse
 
coly010 profile image
Colum Ferry

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

Thread Thread
 
jdforsythe profile image
Jeremy Forsythe

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