This project is read-only.

Single file output does not work with extends

Topics: General, Language Specification
May 18, 2013 at 10:49 AM
Edited May 18, 2013 at 10:51 AM
Extends clause does not work when concatenating and emitting output to single file. The generated output seems to have the classes in the wrong order. Varying results can be achieved by changing the order in which files given in the tsc command line.

class Parent {
class Child extends Parent {
For example:
$ tsc --out out.js Child.ts Parent.ts && node out

    __.prototype = b.prototype;
TypeError: Cannot read property 'prototype' of undefined
    at __extends (typescript-extends-undefined-bug\out.js:3:21)
    at typescript-extends-undefined-bug\out.js:7:5
    at Object.<anonymous> (typescript-extends-undefined-bug\out.js:13:3)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:901:3
And when switching the argument file order, no error:
$ tsc --out out.js Parent.ts Child.ts && node out
Typescript version Node.js version v0.10.1.
May 20, 2013 at 7:34 AM

Try to switch the order:
$ tsc --out out.js Child.ts Parent.ts && node out

I've noticed the same error in my projects, and the file order does matter when compiling. It shouldn't though? Hope this gets fixed.
Jul 24, 2014 at 3:44 PM
Sure you can specify file order manually. It will be really nice if typescipt produce properly ordered output file with "combine" option is set.