| zasetapowanie projektu | npm init -y |
| instalacja TypeScript | npm i -g typescript |
| kompiluje z Ts na js | tsc |
| instaluje ts globalnie, bez tego nie dziala tsc | npm install typescript - g |
| wersja typeScript | tsc -v |
| //kompiluje i --watch sprawdza czy byly zmiany | "scripts": { "compile": "tsc --watch" }, |
| zmienna typu number | let age: number = 29; |
| zmienna ma byc typu Element | const input1Element: HTMLInputElement |
| let age = 29; | inferencja typow(type inference), czyli automatycznie przypisuje: number |
| nie przypisanie wartosci na poczatku spowoduje brak bledu. | let age; age = 0; age = "string" |
| parametr funkcji | function x(par1, par2) |
| unionType | age: number | string |
| pobiera informacje z url | const hasDiscount = new URLSearchParams(window.location.search).get( "discount" ); |
| tablica obiektow | const tasks: { name: string; done: boolean; }[] = |
| reużywalne | interface Task { title: sting; done: boolean } |
| optional property, czyli nie krzyczy jak tego pola nie bedzie | interface Task { title?: sting; } |
| mozna przypisac do te zmiennej tylko "seven" lub "kill bill" | let movie = "seven" | "kill bill"; |
| superset JS | TypeScript |