Search code examples
typescriptintellisensewebstormbabeljsdefinitelytyped

WebStorm - TypeScript and allowSyntheticDefaultImports flag


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).


Solution

  • 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");