index.ts
interface Cat { name: string run(): void } interface Fish { name: string swim(): void } function isCat(animal: Cat | Fish): boolean { return Boolean((animal as Cat).run) }