Order of typescript classes in output.js depends on which file was saved last

Hi guys,

I've got a local typescript project setup in webstorm, using a file watcher with "--out" and "tack only root files" checked.
Also I have a references.ts which contains a reference to every relevant file in the project, which I include in every file.

All seemed to go well at first, but now I'm running into a problem where classes are undefined when I run the code in the browser. The strange thing is, it's a different error (from a different class being undefined) every time, and then occasionally it works.

Then I noticed that the position of a specific class in the output code main.js seems to depend on which .ts file I saved last.
EDIT: in fact, specifically: the file I saved last will also be the last class in the output main.js.

This seems very strange to me, I wonder how this works. Should the output not always get generated starting from main.ts? Or does it indeed somehow start from the last file I save? And if so, how can it be that the output is different when all files have a reference to the same references.ts file?


Anyone any idea?

I'll attach my file watcher settings.
And my file structure looks something like this:

- bin/
  -  index.html
  -  js/
    - main.js
- src/
  - main.ts
  - maincontroller.ts
  - lots_of_folders_here/
    - with_lots_of_classes_depening_on_eachother.ts

Edit: I also just tested this with main.ts in the rootfolder instead of in "src/", the issue remained.



Attachment(s):
typescript filewatcher webstorm.jpg
1 comment
Comment actions Permalink

Ah, I found the answer now. (http://devnet.jetbrains.com/message/5480808#5480808)

I changed the arguments of the TypeScript file watcher to:
--sourcemap $ProjectFileDir$\src\main.ts --out $ProjectFileDir$\bin\js\main.js

so that the process always starts from main.ts, not the file that was saved!

0

Please sign in to leave a comment.