Comment Comment by littlecranky67 Typeguard is what you are looking for: function isDog(animal: Dog | Cat): animal is Dog { return "bark" in Dog }Then: isDog(animal) ? animal.bark() : animal.meow() You get full type narrowing inside conditionals using typeguards. parent littlecranky67 8 months ago
Then: isDog(animal) ? animal.bark() : animal.meow() You get full type narrowing inside conditionals using typeguards.