TypeScript dependencies

Is it a way to "refresh/recompile" TypeScript files which depends on other files using File Watcher functionality? Here is my scenario:
1) I've got two files A and B.
2) B depends on A
3) I'm changing A (for instance I'm deleting some methods/functions) which breaks B
4) But unfortunatelly I can see that something is broken in B when I manually changed B or update its file modification time which triggers File Watcher to recompile B

1) Can File Watcher be somehow configure to recompile B even though it has not been changed?
2) Alternatively can File Watcher recompile multiple files using a single call to TypeScript compiler? I wrote a script which updates all file timestamps in my project causing WebStorm to recompile all - which works fine. The only problem I have with this workaround is that it executes compiler for every single file which is quite time consuming (and CPU rockets as you are using multiple instances and the whole system looks frozen for a while)?

Saying all that I think WebStorm 6 EAP is amazing. I've never used before (although I'm a big fan of Resharper for many years) and WebStorm looks like the only viable option for TypeScript development on the market (at the moment Visual Studio with TypeScript is useless for anything but Hello world! application as it keeps crashing/freezing).

Comment actions Permalink

Well .. since I do not know how exactly you have set it up, here is one of possible suggestions:

  1. Create custom scope (Settings | Scopes) that will include all files that participate in such "dependency chain" (in our test case: A and B)
  2. Create some bat/shell file/phing target (or whatever) that will recompile all required/affected files manually (compile A; recompile B)
  3. Create custom File Watcher entry -- it will use that scope (defined in #1) and that tool (created in #2)

As a result -- if you make any changes in either A or B both files will be recompiled. You can tweak this idea to suit your real needs.

Comment actions Permalink

Andriy, you are ingenious!
I even didn't have to create scopes - just pointed TypeScript compiler to the root files of my project in TypeScript File Watcher instead of using $file$ macro and everything works exactly how I wanted.
It is amazing that File Watchers are so flexible.

Many thanks.

Comment actions Permalink


>>just pointed TypeScript compiler to the root files of my project in TypeScript File Watcher instead of using $file$ macro and everything works exactly how I wanted.

I've also tried to point the TypeScript compiler to ts files in my project (they are in a dedicated Models folder) using Arguments but it doesn't work for me :-(
Can you please specify your approach more exactly?

Arguments: --target ES5 --sourcemap $FileDir$
...results in:
C:\Users\Artur\AppData\Roaming\npm\tsc.cmd --target ES5 --sourcemap C:\Users\Artur\WebstormProjects\KnockoutSpielwiese\Models
Unknown extension for file: "C:\Users\Artur\WebstormProjects\KnockoutSpielwiese\Models". Only .ts and .d.ts extensions are allowed.

Arguments: --target ES5 --sourcemap $FileDir$\*.ts
...results in:
C:\Users\Artur\AppData\Roaming\npm\tsc.cmd --target ES5 --sourcemap C:\Users\Artur\WebstormProjects\KnockoutSpielwiese\Models\*.ts
Error reading file "C:\Users\Artur\WebstormProjects\KnockoutSpielwiese\Models\*.ts": File not found


Comment actions Permalink

I guess my scenario was a bit simpler than yours. I have an application which is spanning from a single TS file - like a bootstrapper. Although it references 80 ts files (including sub-dependencies), I have one entry point hence all I changed in TypeScript File Watcher Arguments was:
--sourcemap "$ProjectFileDir$\Aurora\Aurora.ts"

It works for me since whichever file I change, TS compiler will recompile Aurora.ts which is "dragging" behind the compilation of the whole solution.
I hope this is helpful.

Comment actions Permalink

I have the excact same setup and was looking for this solution! thank you!


Please sign in to leave a comment.