Can I set different compile option for different TypeScript files in WebStorm

Hi, Everyhero.

I am developing an Electron( app using TypeScript 1.4 on WebStorm 10.0.4.

Some .ts files run on Electron main process(NodeJS), so I need to compile them with command option --module commonjs,
and some .ts files run on Electron render process(HTML), so I need to compile them without command option --module commonjs.

In Settings->Languages & Frameworks->TypeScript, I choose Scope to Current File, and set the command line option for file A,
The file B also becomes to use that command line opton..

Can Anyhero know how to resole my problem? Thank U very much first!

Comment actions Permalink

there is currently no way to define different compiler options for different scopes:( Please vote for
For now the only workaround is using file watchers instead of built-in compiler service - you can define several file watchers, one for each of your scopes, and provide different options

Comment actions Permalink

Thank U!
It resolved my problem.
Although It's not perfect, WebStorm IDE will show the error below,but the .ts file compiled to .js file by file watcher correctly, Yes it works!

Error:(5, 1) TS1148: Cannot compile external modules unless the '--module' flag is provided.


Please sign in to leave a comment.