TypeScript - separating code output
Posted
by
Andrea Baccega
on Stack Overflow
See other posts from Stack Overflow
or by Andrea Baccega
Published on 2012-10-03T11:54:40Z
Indexed on
2012/10/04
15:39 UTC
Read the original article
Hit count: 291
TypeScript
|code-separation
i'm trying typescript and I find it very useful.
I've a quite large project and i was considering rewriting it using typescript. The main problem here is the following:
file A.ts:
class A extends B {
// A stuff
}
file B.ts:
class B {
// B stuff
}
If I compile A.ts with this command:
tsc --out compiledA.js A.ts
I'll get error from the compiler cause he doesn't know how to threat the "B" after extends.
So, a "solution" would be including in A.ts (as first line of code):
/// <reference path="./B.ts" />
Compiling again A.ts with the same command
tsc --out compiledA.js A.ts
Will result in compiledA.js containing both B.ts and A.ts code. ( which could be very nice )
In my case, I only need to compile the A.ts code in the compiledA.js file and I don't want the B.ts stuff to be in there.
Indeed, what I want is:
- tsc --out A.js A.ts => compile only the A.ts stuff
- tsc --out B.js B.ts => compile only the B.ts stuff
I can do it by removing the "extends" keyword but doing that I'll loose most of the typescript goodness.
Can someone telll me if there's a way to do this ?
© Stack Overflow or respective owner