question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not all getter/setter references are detected when using JavaScript

See original GitHub issue

Bug 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:open
  • Created a year ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
RyanCavanaughcommented, Jul 8, 2022

@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

0reactions
komygcommented, Jul 8, 2022

@RyanCavanaugh I’d like to help out with this bug. Could you assign it to me?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found