You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm compiling a number of .ts files and using the --out option to concatenate them into a single .js file. I've got some files in different folders, and using internal modules. Without <reference path=... to reference the .js, the compiler still finds the files just fine:
However, when it concatenates, It may place them in the wrong order (though it seems like files in the same folder are in the right order). Since it is basing that only on the reference path, which I did not include. As a result, I may get undefined when importing Widget. If the compiler is compiling a set of files, could it not use the import and module names to order the files appropriately? This would eliminate the need for the reference path, unless the thing being referenced is not part of the compile.
We have followed an axiom not to reorder user code. So the compiler will honor input order. issue #21 is tracking issuing an error if the order is guaranteed to fail at run time, e.g. extends for an undefined class.
The order of files in output is defined by order of files passed to the compiler on the command line. then by following any /// tags that are included in these files and any import statements..
To manage order you have a few options:
Passing dependencies first on the command line when calling the compiler
Add /// references declaring dependency between your files -- some users create an index.ts/_references.ts file that is just a list of /// references declaring the project order, also note that _references.ts is honored by MSBuild and VS
Add a tsconfig.json file in your project directory with a property "files" that specify your order -- see PR Support for tsconfig.json files #1692 for more details
You can find more information about ordering files in the output in this issue #1066
Add a tsconfig.json file in your project directory with a property "files" that specify your order -- see PR #1692 for more details
This is another reason for supporting globs or similar (as mentioned in the previous issue #1516 (comment)).
The minute we add one file to files in order to specify the ordering we are obliged to add _all_ the files in the project.
The solution of using a mix of ///<reference> and tsconfig is not very appealing. I mean we have a situation where A: "This is not compiling" B: "Did you check tsconfig?" A: "Yes" B: "Also check if /// exist".
Activity
mhegazy commentedon Feb 26, 2015
We have followed an axiom not to reorder user code. So the compiler will honor input order. issue #21 is tracking issuing an error if the order is guaranteed to fail at run time, e.g. extends for an undefined class.
The order of files in output is defined by order of files passed to the compiler on the command line. then by following any /// tags that are included in these files and any import statements..
To manage order you have a few options:
You can find more information about ordering files in the output in this issue #1066
NoelAbrahams commentedon Feb 26, 2015
Mohamed Hegazy (@mhegazy),
This is another reason for supporting globs or similar (as mentioned in the previous issue #1516 (comment)).
The minute we add one file to
filesin order to specify the ordering we are obliged to add _all_ the files in the project.The solution of using a mix of
///<reference>andtsconfigis not very appealing. I mean we have a situation where A: "This is not compiling" B: "Did you check tsconfig?" A: "Yes" B: "Also check if /// exist".That's just confusing.
mhegazy commentedon Feb 26, 2015
Noel Abrahams (@NoelAbrahams) i agree globs is a useful addition, i have filed #2154 for it.