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 MyReadonly2<T, K extends keyof T = keyof T> = { | |
| readonly [P in K] :T[P] | |
| } & { | |
| [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
| /* _____________ Your Code Here _____________ */ | |
| type If<C extends boolean, T, F> = C extends true ? T: F | |
| /* _____________ Test Cases _____________ */ | |
| import type { Equal, Expect } from '@type-challenges/utils' | |
| type cases = [ | |
| Expect<Equal<If<true, 'a', 'b'>, 'a'>>, | |
| Expect<Equal<If<false, 'a', 2>, 2>>, |
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 MyAwaited<T> = T extends PromiseLike<infer A> ? MyAwaited<A> : T; | |
| /* _____________ Test Cases _____________ */ | |
| import type { Equal, Expect } from '@type-challenges/utils' | |
| type X = Promise<string> | |
| type Y = Promise<{ field: number }> | |
| type Z = Promise<Promise<string | number>> | |
| type Z1 = Promise<Promise<Promise<string | boolean>>> | |
| type T = { then: (onfulfilled: (arg: number) => any) => 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 MyExclude<T, U> = T extends U ? never: 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 Length<T extends readonly unknown[]> = T['length'] |
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 First<T extends any[]> = T extends [infer P, ...unknown[]] ? P : 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
| // this version using any | |
| type TupleToObject<T extends readonly (keyof any)[]> = { | |
| [A in T[number]]: A | |
| } | |
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 MyReadonly<T> = { | |
| readonly [A in keyof T]: T[A] | |
| } |
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 MyPick<T, K extends keyof T> = { | |
| [key in K]: T[key] | |
| } |
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
| docker exec -it open-webui rm /app/backend/data/webui.db |