-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Union of two interfaces rejects keys that should be acceptable #18421
Comments
type Thing = ThingTypeTwo | ThingTypeTwo; I'm pretty sure you meant to say: type Thing = ThingTypeOne | ThingTypeTwo; |
Partial
of union type disallows one side of the union
@ahejlsberg Yep sorry about that, I've updated the original description with a new failing code sample that should illustrate this better, and updated the issue title to match. |
@dylanpyle |
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed. |
@olegdunkan et al, Could someone explain why EDIT: Ah, this issue is a duplicate of #12052, in which it is mentioned by @ahejlsberg that these two types are equivalent, but the compiler doesn't establish the equivalence because it is rare in practice to encounter a union type that can be represented as a non-union type with a union property. Now I have a good answer to an SO question. |
Update: I submitted a bad code sample the first time around — I've updated this to reflect something that seems actually broken.
--
TypeScript Version: 2.5.2
Code
Expected behavior:
No error
Actual behavior:
It looks to me like the issue is that the compiler doesn't figure out the union of keys within the interfaces. If that's true, it seems strange to me that this is a breaking error since this code should work just fine.
The text was updated successfully, but these errors were encountered: