Reputation: 26547
I'm using TypeScript to compile some files which reference each other. The files reference each other.
The problem is when I compile them, it includes the compiled contents of the file it references as well.
Example:
// in Foo.ts
class Foo {}
// in Bar.ts
/// <reference path='./Foo.ts'/>
class Bar extends Foo {}
The output if I tried to just compile Bar.ts would also include the code for Foo.
Based on another thread (mentioned below), it looks like it does this if you use the --out parameter. However, I need to use the out parameter, but don't want it linked (because I'll hook things back up myself).
Does anyone have any idea how to separate these two bits of functionality?
Note: This is not a duplicate of Referencing TypeScript file includes whole file in output because that is purely for using Web Essentials. I'm using the command-line compiler directly, though the issue is similar.
Upvotes: 2
Views: 1589
Reputation: 532
I am suffering with the same thing. Here is a discussion on codeplex about it, which also references a bug regarding references. Please vote it up in case that helps.
We are building a modular SDK, so this repeated code is a real problem. We ended up using the references only for the Visual Studio tooling, and a custom build system to generate the JavaScript. The system builds the .d.ts decls for all dependency modules and then uses those decls to build dependent modules, passing the --noresolve
flag to prevent <reference ...>
being picked up.
Upvotes: 1
Reputation: 220964
If you pass a directory name (instead of a file name) to the -out switch, you'll get separate compilation. You'll need version 0.8.2 or later to do this.
Upvotes: 2