-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
infer type of tuple from single elements #15484
Comments
suggestion workaround with objects instead tuples: 15482 |
Yeah, I still think fixing this or #15482. TypeScript could narrow these types. Certainly related though. |
i think that it should be a killing feature because in my case i can use the type system to signal to the user that is trying to access the resolved value of the promise without checking the error before, because if you don't check the err variable the resolved value will have a null | T type, after checking the error the type will be correctly T. |
no plan to see this FR approved soon? |
Duplicate of #12849 |
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed. |
hi,
while working on await-to-ts i discovered that i cannot publish the to function with the return type of Promise<[Error, null] | [null, T]> but only with Promise<[Error, T]> because it cannot infer correctly the tuple type on partial informations on elements. you can find a live example of this in this branch
TypeScript Version: 2.3.1
Code
playground link
Expected behavior:
based on partial informations, the type system should be able to infer tuple type correctly.
Actual behavior:
the type system fails to infer tuple types with partial informations about elements.
The text was updated successfully, but these errors were encountered: