Comment on TypeScript 6.0 RCparentComments−dimava6moAnd then you have a const CatDog = { bark(){}, meow(){} } and const TreeCat = { bark: "oak", meow(){} } and your code stops workingTo make types discriminatable you need either type A = { bark: fn, meow?: never } | { bark?: never, meow: fn } type B = { species: "dog", bark: fn } | { species: "cat", meow: fn } or use instanceof with a class
Comments
And then you have a
and and your code stops workingTo make types discriminatable you need either