This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const p1 = new Promise<Promise<Number>>((resolveOuter) => { | |
| const innerPromise = new Promise<Number>((resolveInner) => { | |
| console.log('Resolving inner promise') | |
| resolveInner(1) | |
| }) | |
| console.log('Resolving outer promise') | |
| resolveOuter(innerPromise) | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // constraints | |
| exists type Foo extends { hello: string }; | |
| // type parameters | |
| exists type Foo<T>; | |
| // both! | |
| exists type Foo<T, U> extends { toString(): string }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| exists type Foo extends { | |
| hello: string | |
| }; | |
| // works! | |
| type Foo = { | |
| hello: string; | |
| world: number; | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| exists type Bar extends { | |
| hello: string; | |
| } | |
| // error! | |
| type Bar = { | |
| hello: number; // <- wrong implementation of 'hello' | |
| world: number; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const nestedPromise = new Promise( | |
| (r1) => r1(new Promise( | |
| (r2) => r2(new Promise( | |
| (r3) => r3(42) | |
| ))))); | |
| nestedPromise.then((x) => console.log(x)); //prints 42 | |
| console.log(await nestedPromise); //prints 42 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| try { | |
| throw 42; | |
| } catch (err: unknown) { // Error: TS1196: Catch clause variable cannot have a type annotation | |
| console.error("oops"); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ echo "Hello world" > hello.txt | |
| dsebastien@trankillux MINGW64 /c/Users/dsebastien/wks/tmp (master) | |
| $ cat hello.txt | |
| Hello world | |
| dsebastien@trankillux MINGW64 /c/Users/dsebastien/wks/tmp (master) | |
| $ ls | |
| total 21K | |
| drwxr-xr-x 1 dsebastien 197121 0 May 19 10:05 . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ git status | |
| On branch master | |
| No commits yet | |
| Untracked files: | |
| hello.txt | |
| nothing added to commit but untracked files present |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ git status | |
| On branch master | |
| No commits yet | |
| Changes to be committed: | |
| new file: hello.txt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ echo "I am a Git newcomer" > hello.txt | |
| $ git status | |
| On branch master | |
| No commits yet | |
| Changes to be committed: | |
| new file: hello.txt | |
| Changes not staged for commit: |