added whole content

This commit is contained in:
Fedor Katurov 2022-11-03 10:38:11 +06:00
parent 07a306a6f4
commit dd104eed49
70 changed files with 5962 additions and 19 deletions

View file

@ -0,0 +1,20 @@
Useful for type checking at compile and run time:
```typescript
function isFish(pet: Fish | Bird): pet is Fish {
return (pet as Fish).swim !== undefined;
}
```
Usage:
```typescript
const pet = getSmallPet();
if (isFish(pet)) {
pet.swim();
} else {
pet.fly();
}
```