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
| /* _____________ Your Code Here _____________ */ | |
| type Pop<T extends any[]> = T extends [...infer P, any] ? P: []; | |
| /* _____________ Test Cases _____________ */ | |
| import type { Equal, Expect } from '@type-challenges/utils' | |
| type cases = [ | |
| Expect<Equal<Pop<[3, 2, 1]>, [3, 2]>>, | |
| Expect<Equal<Pop<['a', 'b', 'c', 'd']>, ['a', 'b', 'c']>>, |
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 Last<T extends any[]> = T extends [...any, infer B] ? B: never; |
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 TupleToUnion<T extends unknown[]> = T[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
| type DeepReadonly<T> = { | |
| readonly [K in keyof T]: | |
| T[K] extends Function | |
| ? T[K] | |
| : T[K] extends { [K in string] : any} | |
| ? DeepReadonly<T[K]>: T[K] | |
| } |
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 MyOmit<T, K extends keyof T> = { | |
| [P in keyof T as P extends K ? never: P] :T[P] | |
| } |
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 MyParameters<T extends (...args: any[]) => any> = T extends (...any:infer S) => any ? S: 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 Unshift<T extends unknown[], U> = [U, ...T] |
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 Push<T extends unknown[], U> = [...T, U] |
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 Includes<T extends readonly any[], U> = | |
| T extends [infer First, ...infer Rest] | |
| ? ( | |
| Equal<First, U> extends true | |
| ? true | |
| : Includes<Rest, U> | |
| ) | |
| : false | |
| /* _____________ Test Cases _____________ */ |
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 Concat<T extends readonly unknown[], U extends readonly unknown[]> = [...T, ...U] |
NewerOlder