Intellisense stops working after adding jsconfig file
- VSCode Version: 1.0.0
- OS Version: Windows 10
It seems after I have Code generate a jsconfig file, the intellisense for my imported es6 module seems to quit working.
Initially I have just two files in a folder: script1.js:
export const MyVar = {
a: 5,
b: "hello"
};
script2.js:
import { MyVar } from "./script1.js";
Code gives nice completion while typing in script2.js, telling me MyVar has an a and b property.
I then generate the default jsconfig file. At this point, the code completion for MyVar in script2.js stops working, as well as any other features that require cross-file knowledge (Go to Definition for instance). Code completion also stops working for any npm modules I have installed, imported using es6 module syntax.
Any variables declared in script2.js continue to have intellisense.
Here's the jsonconfig file in case it helps (again, it's just the default):
{
"compilerOptions": {
"target": "es6"
},
"exclude": [
"node_modules",
"bower_components",
"jspm_packages",
"tmp",
"temp"
]
}
@jrieken I was able to reproduce on latest alpha. Use the new trace options shows the following tsserver communication:
Sending request: completions (80). Response expected: yes. Current queue length: 0
Arguments: {
"file": "p:/mseng/VSCode/Playgrounds/bugs/5611/script2.js",
"line": 3,
"offset": 7
}
Response received: completions (80). Request took 8 ms. Success: true
Result: [
{
"name": "MyVar",
"kind": "warning",
"kindModifiers": "",
"sortText": "1"
}
]
Adding the following line to jsonfig.json makes everything work again:
"module": "commonjs"
Should we consider adding this line. Or is this a deeper TS issue
That fixed it for me on 1.0 as well.
I think we left that out in the assumption that TypeScript uses commonjs as default anyways. @egamma might know more
Yes this was also my assumption, but I've found a mail message from March about the module attribute in JS.
From @billti about the module attribute:
This is more a down-level compile setting. It specifies what the emitted module format will be. It defaults to CommonJS, unless you are targeting ES2015 emit.
We are targetting es2015, so it looks like we should add it.
verified that the generated jsconfig.json now includes module: commonjs.
I'm a react developer and I have run into the same issue today.
I'm running vs code 1.4.0 (latest I believe) on a windows 7 machine. after I created jsconfig.json, the react extension (Reactjs code snippets to be specific) stops working. google direct me to this page and I have to delete that jsconfig.json file and re-open my folder. then that code snippet extension start working.
I think the issue might be:
- mis-configuration in jsconfig.json I'm using the default one generated by vs code
{
// See https://go.microsoft.com/fwlink/?LinkId=759670
// for the documentation about the jsconfig.json format
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"allowSyntheticDefaultImports": true
},
"exclude": [
"node_modules",
"bower_components",
"jspm_packages",
"tmp",
"temp"
]
}
do I need to change anything to make that reactjs code snippets work again?
- extension provider's issue
- vs code's issue (or limitation)
any suggestion appreciated