News for hackers. Stuff that matters.
Re:TypeScript: Branded Types by tshaddox on Wednesday April 24, 2024 @06:34PM (#40150684)
> 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);
Re:TypeScript: Branded Types by thepaulmcbride on Wednesday April 24, 2024 @07:22PM (#40151152)
Yep, you’re absolutely right
Re:TypeScript: Branded Types by chrismorgan on Thursday April 25, 2024 @03:56AM (#40154712)
foo.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__.