← Back to context

Comment by culi

9 hours ago

Try it

https://www.typescriptlang.org/play/?#code/C4TwDgpgBAIg9gcyg...

type Mutt = Dog & Cat

const imposter: Mutt = { bark: () => console.log("woof"), meow: () => console.log("meow"), }

You're both misunderstanding parent's point as well as the original point. Nobody ever claimed your link wouldn't compile.

  • I see what you mean, thanks

    Well imo GP is fundamentally misunderstanding TypeScript. It's explicitly a structural language not a nominal one. It goes against the entire design philosophy of TS

    • It would have been a super reasonable reply to talk about the history of TypeScript, why fundamentally its types exist to retroactively describe complicated datastructures encountered in real world JavaScript. And why when TypeScript overstepped that by creating enums, which require code generation and not mere type erasure to compile, it was decided to be a mistake that they won't repeat.

      But instead your rebuttal was pointing out that TypeScript can compile OP's example code, which OP presented as valid TypeScript that they disliked. I'm not defending their position, I'm just saying that it didn't appear you had even properly read their comment.