-
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
Flag JS Literals and ignore assignments/accesses to invalid props, instead of adding an index #25996
Flag JS Literals and ignore assignments/accesses to invalid props, instead of adding an index #25996
Conversation
…ate errors should be ignored instead
One downside of this change (if I'm understanding it correctly) is that not having Having |
You may have told me in person, but: how do the user tests do with this change? |
Since we are touching this area, i agree with @brendankenny that we should make |
19e24a1
to
8d41b63
Compare
@mhegazy Alright, we'll no longer squeltch the errors under @sandersn I fixed a pair of small problems (like also disabling excess property checks on js literals outside of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just some nits about comments.
src/compiler/checker.ts
Outdated
// * unions where every element is a jsliteral | ||
// * intersections where at least one element is a jsliteral | ||
// * and instantiable types constrained to a jsliteral | ||
// Should all count as literals and not print errors on access or assignment of imaginary properties. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
quibble: these properties are not "imaginary". They are "possibly existing" properties.
Seriously, though, I'd say "expando properties". I also don't think that referencing the old implementation helps, so I'd delete that line or at least change it to "This mirrors the behaviour of index signatures".
@@ -9072,6 +9075,34 @@ namespace ts { | |||
return type; | |||
} | |||
|
|||
/** | |||
* Returns if a type is or consists of a JSLiteral object type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move the comment block up here.
I'm going to hold off on merging this until our user/rwc baselines are clean, so we can clearly see its impact on them. AFAIK we're not shipping this in a |
Fixes #25987
As mentioned in-person with @mhegazy, since our goal with the index signature was to just squelch a class of errors in JS, this accomplishes the same thing without the unfortunate side effect of mangling our inferences. This has the fortunate side-effect that the meaningless index signatures are no longer present in quickinfo and the like.
These accesses are also now marked in
noImplicitAny
mode now - which I'd argue is a correct thing to do. That is the breaking change referenced in the PR labels, however in practice it's unlikely to break much (and when it does it's probably desirable!) as JS codebases usingnoImplicitAny
are relatively rare.