|
|
|
Ask HN: TS: Why isn't union type in object field extracted to out of the object?
|
|
3 points
by acomagu
2339 days ago
|
|
I think these type should be equal: { a: string | undefined }
{ a: string } | { a: undefined }
These mean same set of values. And if these are equals, the following works: Exclude<{ a: string | undefined }, { a: string }> // => { a: undefined }
But it don't work as I expected. Because { a: string | undefined } is not { a: string } | { a: undefined }.If it works, Exclude<A, B> could be considered as subtraction of set in mathematical context.
I think there is big deals if these types are equals. Why not?
And please tell me related GitHub issues if you know. |
|
If you would, please post it in issues, that'll be great https://github.com/microsoft/TypeScript/issues