Say I have two files
//a.ts
export class A {
public print() {
console.log("A!");
}
}
and
//app.ts
import A from "./a";
new A().print();
How would I go about setting up the tsconfig so that it outputs both to one file? i.e. kinda like so
class A {
print() {
console.log("A!");
}
}
new A().print();
I can't seem to get outfile to work correctly and when I set module to "AMD", I can't run the code in browser because it's missing "define"
I've tried Typescript compile to single file but that seems to generate define related things that doesn't run on it's own in browser without require.js, when all I want is to condense self contained code into one file? Thank you!
Something like this, though it might depend on your module setting, not sure.
"compilerOptions": {
"module": "none",
"outFile": "Scripts/Output/MyOutputFile.js"
}, "exclude": [
"Scripts/Output/MyOutputFile.d.ts",
"obj/**/*"
]
To avoid problems with the ordering of the source files, make sure to use reference path statements to identify local dependencies in each file. Without this, a dependent file might appear before what it depends on, which leads to unexpected client errors.
/// <reference path="Folder/File.ts"/>
Since I have encountered no end of problems getting the Visual Studio TypeScript compiler to work properly, I manually compile from the command line. This actually led to using MAKE in order to compile all my TypeScript projects in the right order and at the right times. MAKE is pretty complicated, so I'm not sure if I recommend going that route or not.