Change default compiled js file name's suffix

Topics: General
Jan 12, 2014 at 5:52 PM
Edited Jan 12, 2014 at 5:52 PM
I suggest to change the default suffix of compiled js file name.
I think suffix should be something different from ordinary js file.

For example, in version 0.9, "script.ts" is compiled to "script.js" but I think compiled file name should be e.g. "script.ts.js".

Command line option of tsc to specify suffix may be also useful.
(If such a option also exists, please ignore it.)

Reason:
I use git for my TypeScript project. I don't want to add compiled files into my git repository, so I configured not to add *.js files into the repository. (By adding ".js" to .gitignore)
However, after I added a library written in JavaScript, I couldn't do so. I wanted to upload the library and the library's file name ended with ".js"

If the suffix of compiled files are something different from ordinary js files, I can configure to add ordinary js files and not to add js files compiled from ts files.
Jan 13, 2014 at 9:02 AM
If you put all your JavaScript files in one directory you can use .gitignore to ignore compiled TS files but NOT ignore your other JavaScript files.

I built a sample application to demonstrate: https://github.com/wiktor-k/ts-amd/tree/master/scripts

TypeScript files are inside scripts directory but my JavaScript files are ONLY inside the "lib" subdirectory. As I keep the number of JavaScript files as small as possible (actually they're external libraries) this works pretty well for me.

For details check the .gitignore file: https://github.com/wiktor-k/ts-amd/blob/master/scripts/.gitignore

As far as the "add suffix" part goes - it would break loading external modules by require.js (as require('a') looks for a.js file not a.ts.js file but if you used require('a.ts') then TS compiler could complain).
Jan 19, 2014 at 1:52 PM
Edited Jan 19, 2014 at 1:53 PM
As far as the "add suffix" part goes - it would break loading external modules by require.js (as require('a') looks for a.js file not a.ts.js file but if you used require('a.ts') then TS compiler could complain).
I see. Then sepalation by directory seems better.

I found --outDir option after I post this thread, so I made "tscopt" file and wrote following content:
--outDir build
Then I added build/ directory into .gitignore file and compile ts files using "@<file>":
tsc @tscopt code.ts
If you always execute tsc command on the project root, all compiled js files are put under build directory and reproduce the directory hierarchy.

e.g. If you are on PROJECT_ROOT and execute
tsc @tscopt libs/code.ts
then PROJECT_ROOT/build/libs/code.js is generated.