-
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
Using && with spread operator causes "overridden" error if one of the types is "any" #39113
Comments
@andrewbranch is there any guidance for this issue in the time currently. We are on TS 3.8 but would really want to upgrade to TS 3.9 to get the speed and developer improvements. Is there an acceptable workaround :) |
Thanks, that will work for us! Unfortunately after adding that fix to some of our instances we are getting an OOM from the TypeScript compiler. Will try and get a isolated repro case and file a new issue 👍 |
@mastrzyz interesting, you get an OOM going from 3.8 to 3.9? |
@andrewbranch I get the OOM in TS 3.9 when trying to use the workaround with "!!". The file is rather huge so I have been struggling so far to get an isolated repro. |
Same here, getting this with TS 4.0.2, it failing builds. |
@dotansimha yep, it was fixed in 4.1 (see the milestone on this issue) |
@andrewbranch I'm wondering if it would be feasible to backport this to TS 3.9? TS 4.1 is far off and even 4.0 for us is going to be a big change to get onboard. |
No, for the same reason it didn’t go into 4.0 post 4.0-beta—because it was a breaking change. For what it’s worth, 4.0 didn’t contain more breaking changes than any other typical release. I’ve heard anecdotal evidence that it was an easy upgrade—out of curiosity, is there something in it that you know of that makes it difficult? |
Yeah a lot of the changes in TS 4.0 are relatively easy to implement but we have a lot of friction with : We have a very large codebase and many instances of overriding an external libraries properties with accessors. I've been trying to follow the guide to fix them but I think I encountered another TypeScript bug. |
We are having problems with TypeScript 3.9 upgrade for our repositories and the spread operator and "&&" with any types. TypeScript compiler says the value will be always overridden even though an any type isn't 100% always null/undefined.
TypeScript Version: 3.9.5
Search Terms:
Code
Doesn't work
Works
Expected behavior:
any
type can be undefined or can have a non nullable value so we shouldn't get an error with the spread operatorActual behavior:
'display' is specified more than once, so this usage will be overwritten.ts(2783)
Playground Link:
https://www.typescriptlang.org/play/?ssl=1&ssc=1&pln=2&pc=22#code/DYUwLgBAlgzgKgJxCAEiAhgExAiAuCdAOwE8IBeCIgV2GAEIBuAKADNqiBjMKAeyIitevABQBKAN7MISMNQQCpETLAAOwdCQIAiAEbBenANbaANNIB0VkbETI0WHBABkziEpUx1mna1AAPM2kAXzEQ5mC2YXEgA
Related Issues:
The text was updated successfully, but these errors were encountered: