ecmascript-6 - VSCode Intellisense not fully working with ES6 imports?
问题描述
I am having trouble getting Intellisense to work completely with ES6 imports.
Doing the following from /index.js
gets Intellisense to work correctly:
However, doing the following from /index.js
breaks Intellisense:
The directory structure is:
| modules
|-- cars.js
|-- index.js
| index.js
| jsconfig.json
The contents of each file are:
modules/cars.js
export default {
audi: 'R8',
dodge: 'Durango',
};
modules/index.js
import cars from './cars';
export default {
cars,
};
jsconfig.json
{
"compilerOptions": {
"target": "es6",
"module": "commonjs"
},
"exclude": [
"node_modules"
]
}
解决方案
Cars isn't a named export of modules/index.js
. The default export of modules/index.js
is an object, which then contains cars
. To get what you want, make the contents of modules/index.js
this:
export { default as cars } from './cars';
推荐阅读
- scala - 如何在 Spark SQL 和结构化流中转义“是保留关键字,不能用作字段名”错误?
- javascript - 如何在回调前插入http post数据?
- angular - 如何使用实体框架核心在角度上进行服务器端分页
- linux - 在 Linux 中选择 csv 中的首字母
- f# - 当初始化程序具有依赖关系时,F# XUnit 测试死锁
- css - 响应式背景图像滚动
- javascript - 如果以前 e.preventDefault() 在它的按钮上,如何重置表单功能?
- django - 如何解析从模型中查询的 URL?
- clock - cpu时钟如何连接到其他组件
- jquery - 当我选择下拉值时,如何在同一页面中获得计算?