Created
June 3, 2021 02:47
-
-
Save kawanet/b303b87991285da12f739a130f23fb75 to your computer and use it in GitHub Desktop.
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
// オンデマンドに T や Promise<T> を返す関数実装を許容する | |
type OnDemandType<T> = (T | (() => T) | (() => Promise<T>)); | |
// すべてのプロパティがオンデマンド対応 | |
type LazyType<T> = { [K in keyof T]: OnDemandType<T[K]> }; | |
// T や Promise<T> を返す関数実装なら T を取り出す | |
type ResolvedType<T> = (T extends () => Promise<infer P> ? P : T extends () => infer P ? P : T); | |
// T のうち __typename プロパティを無視して、残りのプロパティは必須とする | |
type Implements<T> = Required<Omit<T, "__typename">>; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment