Last active
August 20, 2021 03:08
-
-
Save YouMinTW/0a797366261d1e307acfd1edb9492e6d to your computer and use it in GitHub Desktop.
This file contains 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 Simplify<T> = T extends Function | |
? T | |
: T extends Record<string, any> | |
? { [K in keyof T]: Simplify<T[K]> } | |
: T; | |
type Author = { | |
lastName: string; | |
firstName: string; | |
}; | |
interface Animal { | |
live(): void; | |
} | |
type Kid = { | |
bark: (a: string) => number; | |
qq: { | |
sing: (b: symbol) => boolean; | |
shout: Shout; | |
}; | |
}; | |
type Shout = (a: number, b: boolean, c: string) => Author; | |
type SomeNestedObject = { | |
a: Animal; | |
b: string; | |
c: { a: Animal; d: Kid; e: { a: Kid; b: Animal } }; | |
}; | |
type SimplifiedObject = Simplify<SomeNestedObject>; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment