2016-04-23 1184 views
1

有谁知道为什么VSCode无法识别导入的es6模块?它还没有完全实现,还是我没有正确设置?我无法从他们的文档或搜索谷歌时找到任何解决方案。VSCode无法识别es6语法导入的模块

我有一个typings文件夹与我生成的jsconfig文件一起在根目录中设置。我试过摆弄设置,添加不同的“模块”编译器选项,仍然无法正常工作。

{ 
    // See http://go.microsoft.com/fwlink/?LinkId=759670 
    // for the documentation about the jsconfig.json format 
    "compilerOptions": { 
     "target": "es6" 
    }, 
    "exclude": [ 
     "node_modules", 
     "bower_components", 
     "jspm_packages", 
     "tmp", 
     "temp" 
    ] 
} 

当我使用import express from 'express'它不能识别的模块,但是当我使用import express = require('express')它。

enter image description here

回答

2

你需要你的"compilerOptions"内的以下内容:

"allowSyntheticDefaultImports": true

+0

非常感谢您! –