4 ms·
> As far as I understand classes are the only real way to get nominal typing in TypeScript. Although classes and instances are ultimately structural, right?
by tshaddox 3y ago
> As far as I understand classes are the only real way to get nominal typing in TypeScript.
Although classes and instances are ultimately structural, right?
let foo = new Foo();
assert(foo.constructor == Foo);
- thepaulmcbride 3y agoYep, you’re absolutely right
- chrismorgan 3y agofoo.constructor actually doesn’t matter; foo.__proto__ == Foo.prototype is the one that actually makes things chug, and you can change the class of a value by changing its __proto__.