TypeScript `jest funkcją, określenie typu

type Fish = { swim: () => void }
type Bird = { fly: () => void }
function isFish(pet: Fish | Bird): pet is Fish {
  return (pet as Fish).swim !== undefined;
}

const myFish = { swim: () => {} }

if(isFish(myFish)){
  myFish.swim()
}
Dead Dormouse