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
| # xcode-select --install | |
| # https://dev.to/kurab/check-list-before-re-install-xcode-command-line-tool-295l | |
| $ sudo rm -rf /Library/Developer/CommandLineTools | |
| $ sudo xcode-select --install | |
| # OSX: Error: "xcrun: error: active developer path ("/Applications/Xcode.app/Contents/Developer") does not exist" | |
| # https://github.com/Homebrew/brew/issues/1012 | |
| $ sudo xcode-select --switch /Library/Developer/CommandLineTools |
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
| type Tail<T extends any[]> = ((...t: T) => any) extends ( | |
| _: any, | |
| ...tail: infer TT | |
| ) => any | |
| ? TT | |
| : [] | |
| type Prepend<E, T extends any[]> = ((head: E, ...args: T) => any) extends ( | |
| ...args: infer U | |
| ) => any |
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
| type Prepend<E, T extends any[]> = ((head: E, ...args: T) => any) extends ( | |
| ...args: infer U | |
| ) => any | |
| ? U | |
| : T | |
| type Prepend01 = Prepend<string, []> // [string] | |
| type Prepend02 = Prepend<string, [1, 2]> // [string, 1, 2] | |
| // https://medium.com/free-code-camp/typescript-curry-ramda-types-f747e99744ab |
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
| type Length<T extends any[]> = T['length'] | |
| type Length01 = Length<[]> // 0 | |
| type Length02 = Length<[any, any]> // 2 | |
| type Length03 = Length<[any, any, any]> // 3 | |
| type Length04 = Length<['a', 1, null, string]> // 4 | |
| // https://medium.com/free-code-camp/typescript-curry-ramda-types-f747e99744ab | |
| // https://github.com/millsp/medium/blob/master/types-curry-ramda/src/index.ts |
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
| type Head<T extends any[]> = T extends [any, ...any[]] ? T[0] : never | |
| type HasTail<T extends any[]> = T extends [] | [any] ? false : true | |
| type Tail<T extends any[]> = ((...t: T) => any) extends ( | |
| _: any, | |
| ...tail: infer TT | |
| ) => any | |
| ? TT | |
| : [] | |
| type Last<T extends any[]> = { |
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
| type TupleInfer<T> = | |
| T extends [infer A, ...(infer B)[]] | |
| ? [A, B] | |
| : never | |
| type Type1 = TupleInfer<[name: string, age: number, single: boolean]> // [string, number | boolean] | |
| // https://medium.com/free-code-camp/typescript-curry-ramda-types-f747e99744ab | |
| // https://github.com/millsp/medium/blob/master/types-curry-ramda/src/index.ts |
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
| type ArrayInfer<T> = | |
| T extends (infer U)[] | |
| ? U | |
| : never | |
| const array = [0, 'data', 1, 'foo'] | |
| type Type1 = ArrayInfer<typeof array> // string | number | |
| // https://medium.com/free-code-camp/typescript-curry-ramda-types-f747e99744ab |
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
| type ClassInfer<I> = | |
| I extends Promise<infer G> | |
| ? G | |
| : never | |
| const promise = new Promise<string>(() => {}) | |
| type Type1 = ClassInfer<typeof promise> // string | |
| // https://medium.com/free-code-camp/typescript-curry-ramda-types-f747e99744ab |
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
| export type FunctionInfer<F> = | |
| F extends (...args: infer A) => infer R | |
| ? [A, R] | |
| : never | |
| const fn01 = (arg: number, foo: any) => arg === foo | |
| export type Type1 = FunctionInfer<typeof fn01> // [[arg: number, foo: any], boolean] | |
| // https://medium.com/free-code-camp/typescript-curry-ramda-types-f747e99744ab |
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
| type ObjectInfer<O> = | |
| O extends { a: infer A } | |
| ? A | |
| : never | |
| const object = { a: 'Naruto' } | |
| type Type1 = ObjectInfer<typeof object> // string | |
| type Type2 = ObjectInfer<string> // never |