Created
April 4, 2022 12:48
-
-
Save HenriqueSilverio/898d9e3baac58586584c77b3827670ea 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 Optional<T, K extends keyof T> = Omit<T, K> & Partial<T>; | |
type Test = { | |
foo: string, | |
bar: string, | |
baz: string, | |
daz?: string, | |
} | |
type Test1 = Optional<Test, 'foo'> | |
const test1: Test1 = { | |
bar: '', | |
baz: '', | |
} | |
type Test2 = Optional<Test, 'bar' | 'baz'> | |
const test2: Test2 = { | |
foo: '', | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment