Why do I get Intellisense in vscode when using `require` but not when using `import`

别等时光非礼了梦想. 提交于 2019-12-13 01:24:47

问题


In VS Code, when I import jquery using import $ from 'jquery';, Intellisense isn't working. This is what I get:

However, when using the require syntax, const $ = require('jquery');, Intellisense does work:

This happens with any kinds of import, not only with jquery.

Any way to make Intellisense work when using the import syntax? I am using typings.


回答1:


This is know bug. https://github.com/Microsoft/vscode-react-native/issues/61

Fix is already available in Insiders build. Or you can wait for the stable version 1.0, which will be released in few days.




回答2:


Starting from version 1 (released April 14th 2016), you need a jsconfig.json file at the root of your project with the following content in order to enable Intellisense with the import syntax:

"compilerOptions": {
    "target": "ES6",
    "allowSyntheticDefaultImports": true
}


来源:https://stackoverflow.com/questions/36561203/why-do-i-get-intellisense-in-vscode-when-using-require-but-not-when-using-imp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!