Home Ask Login Register

Developers Planet

Your answer is one click away!

RezaRahmati February 2016

Specify TypeScript output file name format

I need to change the TypeScript generated js file name to something else. How can I do that

For example I have MyCompany.ClassA.ts

It will generate MyCompany.ClassA.js by default

But I want MyCompany.ClassA.generated.js

I took a look at .tsConfig file but I couldn't find anything useful there.

ps. I am using VisualStudio2013 for Typescript and generating the js files


Robert Penner February 2016

To compile a single TypeScript file to .js with a custom name, use --outFile:

tsc MyCompany.ClassA.ts --outFile MyCompany.ClassA.generated.js

Compiling multiple files to the .generated.js pattern would require a bit more work. You could compile one at a time as in the tsc example above.

tsc A.ts --outFile A.generated.js
tsc B.ts --outFile B.generated.js

Or you could use --outDir to collect the compiled files under standard names, and then rename them with your own script.

tsc --outDir ./generated
# run script to rename ./generated/*.js to *.generated.js 

Note that --outFile and --outDir replace --out, which is deprecated:


Post Status

Asked in February 2016
Viewed 3,467 times
Voted 14
Answered 1 times


Leave an answer

Quote of the day: live life