Not all getter/setter references are detected when using JavaScript
See original GitHub issueBug Report
🔎 Search Terms
🕗 Version & Regression Information
export class Foo {
constructor() {
this.bar = false;
this.bar = true;
}
get bar() {
return true
}
set bar(value) {
// Do something with value
}
}
/** @type {Foo[]} */
const items = [];
for (const item of items) {
item.bar = true;
}
🙁 Actual behavior
When clicking this.bar
on line 3, only the instances on line 3 and 4 are highlighted. When pressing F2
only those two instances are renamed, and when pressing F12
(cmd F12
on the playground) only those two instances appear in the list of references.
🙂 Expected behavior
All references, including the getter, setter and item.bar
on line 20 are referenced. This works fine when using TypeScript. See this playground example for the TypeScript equivalent of this code.
https://user-images.githubusercontent.com/2737650/177770729-e9c893c6-7c8a-4228-8fb6-865256cec662.mp4
Issue Analytics
- State:
- Created a year ago
- Comments:7 (6 by maintainers)
Top Results From Across the Web
Javascript: object's setter and getter is lost after clonning ...
I found a solution in this question: What is the most efficient way to deep clone an object in JavaScript? function cloneObject(source) {...
Read more >getter - JavaScript - MDN Web Docs - Mozilla
The get syntax binds an object property to a function that will be called when that property is looked up. It can also...
Read more >Avoid getters and setters whenever possible
I've seen excessive use of getters/setters/properties in Java, C#, Ruby, and Javascript. Changing the syntax does not help. If anything it ...
Read more >Data encapsulation in JavaScript: getters and setters - Invivoo
In the case of properties, keeping an stable interface is not easy. For, by ... Client code won't be able to detect quickly...
Read more >Why getters/setters is a bad idea in JavaScript
Proxy objects can be used to trap any access to the instance of the Class and throw an error if a pre-defined getter...
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
@komyg glad to hear! It’s not possible for me to assign this (you’d need a permission level on the repo that we don’t issue to non-Microsoft employees). See also https://github.com/microsoft/TypeScript/blob/main/CONTRIBUTING.md#issue-claiming
@RyanCavanaugh I’d like to help out with this bug. Could you assign it to me?