-
Notifications
You must be signed in to change notification settings - Fork 12.8k
IntelliSense/autocomplete doesn't work properly inside object literals #48915
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
Comments
@sandersn not sure if this is a known limitation—can you help triage? |
I can't remember, but it's surprising and undesirable enough that I want to double-check. Initial investigation shows that the problem is in the checker, not completions. Compare the type of export { }
let obj = {
x: 10,
y: [1],
fun: function() {
this.x = 1
this/*1*/
},
f2: function() {
this.x
this/*2*/
}
} In I'm pretty sure that the assignment to |
Is it possible to write a class and export it via CommonJS in such a way that we can't actually figure out if it's supposed to be a class or object? e.g: Playground Link module.exports = {
SomeClass: function() {
this.x = 1;
}
}
const a = new module.exports.SomeClass()
console.log(a.x) |
I would think you might need |
In fact, IIRC, it used to be the case that all classy-functions needed |
What the heck, ⌘enter changed behavior overnight. |
So just to clarify what we're looking to do, we want to tweak that heuristic such that this issue's case is treated as an object, not as a class? Looking at the playground, it appears as though v4.0 was the first version where the |
That feels reasonable to me, because
It would technically be a breaking change, but it feels worth it if I’m making some assumptions about prevalence of these patterns. Probably should wait until 4.9 though. |
Thanks! I'll bisect this just to see where the behavior changed, but I'll wait for 4.9 to change (especially if it was intentional back then; I'm sure it was). |
#39447 where this particular test changes, as |
Sent #49735; there was an existing test encoding this behavior already. |
Does this issue occur when all extensions are disabled?: Yes
Steps to Reproduce:
let obj = { x: 10, y: [1], fun: function () {}
this
keyword is recognised by the IntelliSense/autocomplete.this.
- results inlet obj = { x: 10, y: [1], fun: function () {
this.x = 5;
}}
x
is recognised by the IntelliSense/autocomplete:Even though
y
property is an array, IntelliSense won't show its methods and properties:System info
A/B experiment info
The text was updated successfully, but these errors were encountered: