-
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
Type inference destructure object #50684
Comments
Also found another bug, but I don't know if it's React types or TypeScript Inference: Playground |
#50604 looks about the same, in that the error message is sort of the same "omitting something that I intersected in"
That one had a workaround (and might be correct?), but it seems like there's a bug here. |
#50604 is definitely working as intended. If Likewise, the pattern in the OP here (and my reduced case) should be an error, since
This makes me think that it’s an error for a completely incorrect reason. |
While I think something is definitely awry here, I’m going to bump it to the backlog since it shouldn’t compile and it doesn’t. |
Never thought of the case where T could be instanciated with the same Omitted properties, that's correct. Nevertheless in that case the error should be something like #50604, so maybe is something else. Thank you for the clarification! Also, could you take a look to the playground linked here?
Should I make another issue in this repo or should I do it at React Types? I don't know who can be responsible of it. Thank you! |
@herrlegno that’s a duplicate of #241 (congrats, you found a three-digit one!) |
Bug Report
Typescript seems to not be able to infer correctly a rest object type.
I've found a workaround for it by nesting the value (in playground)
🔎 Search Terms
Destructuring
🕗 Version & Regression Information
Tested in 4.5.5, 4.8.2 and next (time of writing = v4.9.0-dev.20220908)
⏯ Playground Link
Playground
💻 Code
🙁 Actual behavior
Throws an error
🙂 Expected behavior
Expect to not throw an error as
Omit<Value & T & { legend: ... }, "legend" }> === Value & T
The text was updated successfully, but these errors were encountered: