In VS Code, i'm making a js file with this piece of code
const ObjectX = {
abc(){
},
xyz(){
this.abc()
},
}
And when I'm typing this.
and press Ctrl + space
I expect VS Code to suggest me with abc()
as a member of this
but it doesn't.
When I type the full line this.abc()
then press F2
at definition line to rename abc()
, VS Code doesn't rename all the calls to this.abc()
as well.
All 2 facts definitely say that VS Code doesn't link the keyword this
to current object. This behavior is inconvenient cause another install of VS on another PC do links.
Anyone experienced this can give me a line of configuration to fix VS Code ?
PS1: This is just bad coding experience with VS Code, not the way javascript code works!
PS2: I've tried TypeScript with the same behavior.
PS3: I have intellisense with newest version of VSCode and my jsconfig.json
looks like this
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"experimentalDecorators": true
},
"exclude": [
"node_modules",
".vscode",
"library",
"local",
"settings",
"temp"
]
}
The answer is simple but hard to find out:
Add this line to tsconfig.json
of project
"compilerOptions": {
....
"noImplicitThis": true
....
}