WebStorm - TypeScript and allowSyntheticDefaultImports flag

允我心安 提交于 2019-12-13 19:22:54

问题


TypeScript 1.8 added allowSyntheticDefaultImports flag.

I have a TypeScript project targeting es6, which afterwards gets transpiled with Babel to ES5.

Currently, WebStorm's intellisense does not recognize this flag, and thus says that using default import from a module which does not export a default is disallowed. This means that I am not getting the definitions correctly..

Since I do not want to update all of the definition files manually, is there any other way to 'teach' WebStorm this rule, until JetBrains officially release a new version which supports it (I already submitted a ticket there).


回答1:


WebStorm doesn't appear to use the TypeScript language service, so there isn't any way that I'm aware of to fix this.

In the mean time you can use non-ES6 style imports:

import foo = require("foo");

which should basically compile down to:

var foo = require("foo");


来源:https://stackoverflow.com/questions/35171858/webstorm-typescript-and-allowsyntheticdefaultimports-flag

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