web:javascript:typescript
Ceci est une ancienne révision du document !
Table des matières
TypeScript
Installation
- Installer node.js
- Installer TypeScript par npm :
# npm install -g typescript
Linting
- Visual Studio Code a une extension : TSLint
- Linter Documentation : TSLint
Pour installer:
$ npm i -g tslint
Compilation / Transpile
En installant TypeScript, on installe un transpiler qui transforme le code TypeScript en JavaScript.
$ tsc fichier.ts
Typings
- Package : typings
Interface
class ICat { name: string; age: number; } let fluffy: ICat;
Classes
class Cat implements ICat { private name: string; private color: string; constructor (name, color) { this.name = name; this.color = color; } speak() { console.log('meow'); } }
Peut être remplacé par :
class Cat implements ICat { constructor (private name, private color) { } speak() { console.log('meow'); } }
Ressources
web/javascript/typescript.1522280660.txt.gz · Dernière modification : 2022/02/02 00:43 (modification externe)