This project is read-only.


tsc --out does not seem to work properly



I am trying to use the --out option with the typescript compiler so that I can get just one output file with all the dependent files concatenated. Unfortunately, it does not seem to work. Firstly, according to the documentation:

Syntax: tsc [options] [file ..]

Examples: tsc hello.ts
      tsc --out foo.js foo.ts
      tsc @args.txt
I should be able to use it like: tsc --out foo.js foo.ts, but doing that gives the following error: module emit collides with emitted script:

So you cannot use the same filename for output as input. Now, I have two files: animal.ts and fox.ts:


export class Animal{
legs : number;
color : string;
console.log("Processing an animal...")

and fox.ts

import AnimalModule = module("./animal");

export class Fox extends AnimalModule.Animal {
legs = 4;
bar : string;
console.log("Processing Fox");
Now if I run tsc --out result.js fox.ts I get the following in result.js:

var __extends = this.__extends || function (d, b) {
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
whereas fox.js and animal.js have been generated correctly (although I would expect no other outputs than result.js):


var AnimalModule = require("./animal")
var Fox = (function (_super) {
__extends(Fox, _super);
function Fox() {
    _super.apply(this, arguments);

    this.legs = 4;
Fox.prototype.process = function () {
    console.log("Processing Fox");
return Fox;
exports.Fox = Fox;


var Animal = (function () {
function Animal() { }
Animal.prototype.process = function () {
    console.log("Processing an animal...");
return Animal;
exports.Animal = Animal;
So what is going in?

Thanks in advance,

Manuel Astudillo.
Closed Feb 19, 2013 at 11:55 PM by RyanCavanaugh
I believe this is fixed now. --out shouldn't have allowed you to specify a single file when having external modules present


samanime wrote Dec 12, 2012 at 2:52 AM

I'm not sure what the issue would be. It looks like to me something like:

tsc animal.ts fox.ts --out animal.js

should work just fine. That's what I do for compiling my rather hefty libraries in to single files.