tsc --out does not seem to work properly

Topics: General
Oct 18, 2012 at 9:22 PM
Edited Oct 18, 2012 at 9:26 PM

Hello,

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:

animal.ts

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

and fox.ts

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

export class Fox extends AnimalModule.Animal {
  legs = 4;
  bar : string;
  process(){
    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):

fox.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;
})(AnimalModule.Animal);
exports.Fox = Fox;

animal.js:

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.

Oct 18, 2012 at 9:23 PM

I forgot to mention that I am using this with node js version 0.6.20 and typescript version 0.8.0

Coordinator
Oct 19, 2012 at 4:43 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Oct 19, 2012 at 7:18 PM
Edited Oct 19, 2012 at 7:18 PM

...

Coordinator
Oct 19, 2012 at 11:29 PM

I moved this over to the issue tracker to get feedback there whether or not this was expected (and if it's a bug, to help get it fixed).  Hope that helps.