Add related error spans for getter/setters with different types
See original GitHub issueNow that we support multiple related spans for errors (#10489, #22789, #24548), we’d like to improve an existing error message.
Currently, we provide a diagnostic for a pair of get
/set
accessor’s types not matching:
Code:
let x = {
get foo() { return 100; }
set foo(value: string): { }
}
Current error:
'get' and 'set' accessor must have the same type.
We’d like to give a better error message. For example:
Primary span:
A 'get-' and 'set-' accessor must have the same type, but this 'get' accessor has the type '{0}'.
Related span:
The respective 'set' accessor has the type '{0}'.
Issue Analytics
- State:
- Created 5 years ago
- Comments:17 (7 by maintainers)
Top Results From Across the Web
Is there a way to dynamically map keys to getters/setters of ...
I know these are not real getters and setters but it mimics the behaviour. type Example = { prop: number; }; type Mapped<T>...
Read more >Using Widgets in Catalog Items - ServiceNow Elite
Use widgets within catalog items and build awesome customizations for your Service Catalog.
Read more >Documentation - TypeScript 3.9
The function's types declare that it takes two string s so that other TypeScript users can get type-checking errors, but it also does...
Read more >ngModelOptions - AngularJS: API
This directive allows you to modify the behaviour of ngModel directives within your application. You can specify an ngModelOptions directive on any element....
Read more >Getters And Setters In Java: Common Mistakes, And ... - Xperti
Mistake 3: Returning the object reference directly in the getter. Mistake 4: Writing getters and setters in Java for mutable data types. Mistake...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
setters and getters MAY HAVE different types
Another example:
@RyanCavanaugh
There is no restriction on
get
set
in ECMA specification, so adhering to the standard, shouldn’t this restriction be lifted? I mean “‘get’ and ‘set’ accessor must have the same type”.