Closed ccorcos closed 6 years ago
I believe we can fix this now with conditional types:
type Omit<T, K extends keyof T> = T extends any ? Pick<T, Exclude<keyof T, K>> : never
https://github.com/Microsoft/TypeScript/issues/12215#issuecomment-378589263
AFAIK In v0.3 Omit
does preserve optional props
interface A {
a: string
b?: number
c: boolean
}
type B = Omit<A, 'a'>
/*
type B = {
b?: number | undefined;
c: boolean;
}
*/
Oops, I was supposed to post that comment in https://github.com/gcanti/typelevel-ts/issues/11.
You may have ran into this TS bug: https://github.com/Microsoft/TypeScript/issues/20722