Skip to content

Instantly share code, notes, and snippets.

@pspi
Last active December 21, 2015 18:49
Show Gist options
  • Save pspi/6350429 to your computer and use it in GitHub Desktop.
Save pspi/6350429 to your computer and use it in GitHub Desktop.
Using grunt-ts reference file as workaround to typescript command line source file ordering issues
class Child extends Parent {
}
module.exports = function(grunt) {
grunt.loadNpmTasks("grunt-ts");
grunt.initConfig({
ts: {
default: {
src: ["*.ts"],
reference: "reference.ts",
out: 'out.js'
}
}
});
}
class Parent {
}
@basarat
Copy link

basarat commented Aug 27, 2013

You need to manually edit the generated reference.ts to ensure that Parent comes before Child.

/// <reference path="Parent.ts" />

//grunt-start
/// <reference path="Child.ts" />
/// <reference path="someotherfile.ts" />
/// <reference path="automaticallyInserted.ts" />
//grunt-end

It is still useful because:

  • its easy to the reference.ts to do ordering
  • you don't have that many base classes
  • for applications like angular that do a lot of dependency injection order for most of your files doesn't matter http://www.youtube.com/watch?v=Km0DpfX5ZxM&hd=1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment