Last active
July 27, 2021 14:56
-
-
Save wzhudev/fdf122eb44433957f5e2b6fdd61e3693 to your computer and use it in GitHub Desktop.
Revisions
-
Wendell revised this gist
Jul 27, 2021 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -42,6 +42,12 @@ type MyExclude<T, U> = T extends U ? never : T; Actually, it runs for each sub type of a union type. 189. Awaited ```ts type Awaited<T extends Promise<any>> = T extends Promise<infer U> ? U : never; ``` 533. Contact ```ts -
Wendell revised this gist
Jul 27, 2021 . 1 changed file with 9 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -26,14 +26,22 @@ type MyReadonly<T> = { type First<T extends any[]> = T['length'] extends 0 ? never : T[0]; ``` Perhaps you don't know you can get `length` of an array type. 18. Lengh of Tuple ```ts type Length<T extends readonly unknown[]> = T['length']; ``` 43. Exclude ```ts type MyExclude<T, U> = T extends U ? never : T; ``` Actually, it runs for each sub type of a union type. 533. Contact ```ts -
Wendell revised this gist
Jul 27, 2021 . 1 changed file with 14 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -20,6 +20,20 @@ type MyReadonly<T> = { } ``` 14. First of Array ```ts type First<T extends any[]> = T['length'] extends 0 ? never : T[0]; ``` Perhaps you don't know you can get 'length' of an array type. 18. Lengh of Tuple ```ts type Length<T extends readonly unknown[]> = T['length']; ``` 533. Contact ```ts -
Wendell revised this gist
Jul 27, 2021 . 1 changed file with 23 additions and 5 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,13 +1,31 @@ # Solutions ## Warm-up ## Easy 4. Pick ```ts type MyPick<T, K extends keyof T> = { [U in K]: T[U]; } ``` 10. Readonly ```ts type MyReadonly<T> = { readonly [U in keyof T]: T[U]; } ``` 533. Contact ```ts type Concat<T extends unknown[], U extends unknown[]> = [...T, ...U]; ``` ## Medium ## Hard -
Wendell revised this gist
Jul 27, 2021 . 1 changed file with 12 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,2 +1,13 @@ # Warm-up # Easy [533. Contact](https://github.com/type-challenges/type-challenges/blob/master/questions/533-easy-concat/README.md) ```ts type Concat<T extends unknown[], U extends unknown[]> = [...T, ...U]; ``` # Medium # Hard -
Wendell created this gist
Jul 27, 2021 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,2 @@ ```ts ```