I tried to use typescript and I couldn't figure out something that I think should be a simple thing to do.
Let's say I have this structure:
geom/Shape.ts: this is a Shape class within a "geom" module.
Main.ts - the Main class that uses the geom.Shape class (eg. creates instances of it)
I'd like to compile these into a single js file but I couldn't figure out how.
If I use these options:
--sourcemap $FileName$ --out app.js geom.Shape.ts Main.ts
--sourcemap $FileName$ --out app.js Main.ts
the compilation breaks with an error:
error TS5007: Cannot resolve referenced file: 'geom.Shape.ts'.
Generally what would be awesome to have multiple modules, each having multiple .ts files, each .ts file is a typescript class, and I could just compile all of it into one js file.
Is this somehow possible with a compiler flag?
Jan 10, 2014 at 8:15 PM
Is the filename geom/Shape.ts or geom.Shape.ts?
thanks for the reply. It was "Shape.ts". inside the geom folder.
In the meantime I could manage to solve this compile error by using this in the Main:
With this, even circular dependencies seem to work! I wonder though, why is this needed? It seems a bit cumbersome to use such annotations.
In the end, ideally, I would love to use typescript as I used to use Java/Actionscript3/etc that is:
- some packages
- each package has some .ts files
- each .ts file has exactly one Class
- circular dependencies are possible
- on compilation it results in a single file, but it doesn't include unused classes
- strong, static typing - which works of course fine with TS
- refactoring - which I have trouble with using WebStorm, although this should work easily, shouldn't it?
All of these seem to be managable in typescript the way I see it!