Search code examples
typescriptecmascript-6webstormcommonjs

ES6 style import statement not working in TypeScript


I'm trying to do simple import/export in TypeScript as follows:

animals.ts

export const someVar=5;

main.ts

import {someVar} from './animals';

But compiler is saying:

Compilation errors

Below are my typescript compiler options:

-t ES6 -m commonjs

I've tried amd in module options as well but with no luck. RequireJs seems to be working fine though.

My TypeScript version is 2.2.2 and using WebStorm IDE.

What am I missing here? Please bear with me as I am new to this.

Edit

tsc main.ts compiles perfectly fine. But WebStorm still whining about compilation errors.


Solution

  • Found the solution. I was using old webstorm 10 that was using typescript compiler version 1.4. I upgraded the webstorm to 2017.1 which uses compiler version 2.2.2. Thanks @Horia Coman for giving hint.