-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Separate read and write types for properties #32821
Comments
@DanielRosenwasser had mentioned this idea as an option for solving runem/lit-analyzer#43 |
We're halfway there as of last Friday and we're looking into expanding it in 3.7. In 3.6 we should parse getters and setters on ambient class declarations, in 3.7 we intend to expand to object and interface types and include better checking rules for them. |
(Although I don't think we have any backlog item for specifically differing getter/setter types yet) |
I don't think it should be limited to properties. We should consider if there's a way to work with divergent bounds on types. We usually think of a type being lower-bounded and upper-bounded by two types (Lower ≤ T ≤ Upper), but I don't know if we've thought much about T ≤ LesserUpper and GreaterLower ≤ T. Maybe that's just intersections of ranged types?
But that doesn't have any overlap, which is strange. Just spitballing here though. |
Could we extend the duality to index access types? |
This is possibly a duplicate of #2521 |
@ExE-Boss indeed. Closing this now. |
Search Terms
[read types and write types], [read type]
Suggestion
Many DOM APIs have setters that coerce values to strings. Using these APIs in perfectly valid ways will result in type warnings:
These APIs could be more accurately described if getters and setters could have different types, like:
Related Issues
#590
#814
Use Cases
Use DOM APIs :)
Also see: runem/lit-analyzer#43
Examples
Shown above
Checklist
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: