Make Webstorm find tsd.d.ts without refering to it in every .ts file
I use tsd to install Typescript definition files. It creates a singel tsd.d.ts file which holds all references.
When I run:
tsc --noemit
on the command line, all works fine.
Then I configure Webstorm to run tsc with --noemit in Settings > Languages & Frameworks > TypeScript > Set options manually > Command line options: --noemit.
Now Webstorm compains that it cannot find modules and I have to add /// <reference path="../typings/tsd.d.ts" /> to every file. Is there some way to make Webstorm understand this like the command line tsc does?
/Jonas
Please sign in to leave a comment.
it's really strange that the same command run in same folder works in terminal and doesn't work in WebStorm....
the easiest way to make this work without specifying ///<reference> tags is using tsconfig.json - if referenced files are included in it, and tsconfig is used for compilation ('Use tsconfig.json' is enabled in Settings/Languages & Frameworks/TypeScript), compiler will use the configuration file when searching for references, and won't need d.ts files being referenced explicitly. See also http://stackoverflow.com/questions/32151141/webstormtypescript-how-to-use-without-reference-path
Problem is I just want to use Webstorm to do checking of typescript, while not emitting any js files (the --noemit option to tsc).
I then use webpack in the terminal, and it uses tsconfig.json with emit.
So if I configure tsconfig.json with noemit, it will work in Webstorm, but then webpack will not work since nothing will be emitted.
Therefore I want to specify --noemit to Webstorm explicitly.
Is there some way to make Webstorm use an alternate tsconfig.json?
Or can we configure Webstorm to just do checking of typescript without emit some other way?
/Jonas
To pass the alternate tsconfig.json to compiler, use the 'set options manually' mode and specify a path to your alternate config using a
(or just ) command line option that specifies the path of a directory containing a fileNow I have:
project_root]/tsconfig.json (for use by webpack)
project_root]/webstorm/tsconfig.json (for use by webstorm, with noemit)
I specify typescript set options manually:
-p C:\...\[project_root]\webstorm
And I get error:
Warning:File was not compiled because there is no a reference from tsconfig.json
Seems like using a separate directory with another tsconfig.json does not work as it will not find the rest of the files....
/Jonas
I almost have it working with a single tsconfig.json file now, I use set options manually and specify:
--noemit -p C:\...\[project_root]
So it uses the regular tsconfig.json but also overrides with --noemit. This works, now I only need to use a relative path instead of an absolute.
Is there some variable which I could use to get the path to the Webstorm project in the comand line options?
/Jonas
Seems like:
--noemit -p .
works. So Webstorm probably makes the project directory the current directory when calling tsc.
No, there is no way to use environment variables there:(
yes, exactly:)