typescript install code example
Example 1: install typescript
npm install -g typescript
Example 2: install typescript in node project
npm i -D @types/node typescript ts-node
Example 3: how to install typescript in windows 10
npm install -g typescript
Example 4: install typescript
Don't forget to use the dev flag!!!
Yarn:
yarn global add --dev typescript
NPM:
npm install -g --save-dev typescript
Example 5: create typescript project
npx tsc index.ts
Example 6: typescript
interface LabelledValue {
label: string;
}
function printLabel(labelledObj: LabelledValue) {
console.log(labelledObj.label);
}
let myObj = {size: 10, label: "Size 10 Object"};
printLabel(myObj);