Created
September 2, 2023 07:42
-
-
Save guiseek/ef695a77d237dd6f39851d8798a3630b to your computer and use it in GitHub Desktop.
Angular Typed Form
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 DetectTypedForm<T> = | |
T extends Array<infer U> | |
? FormArray<DetectTypedForm<U>> | |
: T extends Date | |
? FormControl<Date> | |
: T extends object | |
? FormGroup<TypedForm<T>> | |
: T extends true | false | |
? FormControl<boolean> | |
: T extends PropertyKey | |
? FormControl<T> | |
: FormControl<unknown> | |
export type TypedForm<T> = { | |
[K in keyof T]: DetectTypedForm<T[K]> | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment