Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

typescript narrowing object

type Fish = { swim: () => void };
type Bird = { fly: () => void };
 
function move(animal: Fish | Bird) {
  if ("swim" in animal) { // in operator narrowing
    return animal.swim();
  }
  return animal.fly();
}
Comment

PREVIOUS NEXT
Code Example
Typescript :: how to git pull all projects in a folder 
Typescript :: extract digits with serten lenth from string python 
Typescript :: for (... in ...) statements must be filtered with an if statement (forin) 
Typescript :: ngx-numeral 
Typescript :: Actual instructions in flowcharts are represented in __________ 
Typescript :: When do you choose automated testing over manual testing? 
Typescript :: elastice search requirements in ubunt 
Typescript :: localhost magento 2 installation redirects to the live server 
Typescript :: all default datasets in seaborn 
Typescript :: if you meant to render a collection of children use an array instead 
Typescript :: types of project plan 
Typescript :: check if package exists inside the device adb 
Typescript :: how to get pastebin contents c# 
Typescript :: Link renders blank page 
Typescript :: display only user contributor comments wordpress 
Typescript :: get ols regression results with for loop for dataframe against a constant 
Typescript :: angular stop dialog stacking 
Typescript :: 1st heghts value in sql 
Typescript :: rapists near me 
Typescript :: Show that the speed of the spacecraft in its orbit is 3.7 × 103ms –1. 
Typescript :: Error detected in pubspec.yaml: No file or variants found for asset: assets/imgs. 
Typescript :: how to use array pop in typescript 
Typescript :: download objects under a prefix in golang 
Typescript :: count number of elements in multi-dimensional array python 
Typescript :: program to obtain sublists 
Typescript :: loading assets in ionic react 
Typescript :: laravel validation exists match with nother column 
Typescript :: positional arguments dart 
Typescript :: TYPESCRIPT PIPLINE FOR THE MULTIPLE TYPE 
Typescript :: nextjs and nodemailer problem after deploy 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =