Skip to content

Instantly share code, notes, and snippets.

@wzhudev
Last active July 27, 2021 14:56
Show Gist options
  • Select an option

  • Save wzhudev/fdf122eb44433957f5e2b6fdd61e3693 to your computer and use it in GitHub Desktop.

Select an option

Save wzhudev/fdf122eb44433957f5e2b6fdd61e3693 to your computer and use it in GitHub Desktop.

Revisions

  1. Wendell revised this gist Jul 27, 2021. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions type-challenges-sollutions.md
    Original 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
  2. Wendell revised this gist Jul 27, 2021. 1 changed file with 9 additions and 1 deletion.
    10 changes: 9 additions & 1 deletion type-challenges-sollutions.md
    Original 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.
    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
  3. Wendell revised this gist Jul 27, 2021. 1 changed file with 14 additions and 0 deletions.
    14 changes: 14 additions & 0 deletions type-challenges-sollutions.md
    Original 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
  4. Wendell revised this gist Jul 27, 2021. 1 changed file with 23 additions and 5 deletions.
    28 changes: 23 additions & 5 deletions type-challenges-sollutions.md
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,31 @@
    # Warm-up
    # Solutions

    # Easy
    ## Warm-up

    [533. Contact](https://github.com/type-challenges/type-challenges/blob/master/questions/533-easy-concat/README.md)
    ## 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
    ## Medium

    # Hard
    ## Hard
  5. Wendell revised this gist Jul 27, 2021. 1 changed file with 12 additions and 1 deletion.
    13 changes: 12 additions & 1 deletion type-challenges-sollutions.md
    Original 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
  6. Wendell created this gist Jul 27, 2021.
    2 changes: 2 additions & 0 deletions type-challenges-sollutions.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    ```ts
    ```