Better file reference for typescript

typescript

Solution

Check out grunt-ts reference file generation : https://github.com/basarat/grunt-ts#reference-file-generation

What you can do is that have seperate targets, one for dev and one for test :

    dev: {                          
        src: ["app/**/*.ts", "!app/**/*.spec.ts"], // Exclude your spec files 
        reference: "./app/reference.ts", 
        out: 'app/out.js',        
    },
    test: {                          
        src: ["app/**/*.ts"], // Include all files 
        reference: "./app/reference.ts", 
        out: 'app/out.js',        
    },

Now you only reference `app/reference.ts`from all your files. When you want to run tests, build for tests, when you want to release / dev build for dev.

Also check out this video tutorial : http://www.youtube.com/watch?v=0-6vT7xgE4Y&hd=1

Problem

I’m fairly new to TypeScript and trying to setup some unit tests for my TypeScript code base. The problem is that my code depends on other's work and all these references are done in the form of hard coded relative paths like “......\somefile.d.ts”. When come to unit test, I want to fake out some of the dependencies but don’t know how to make TypeScript take my Fakes instead of hard coded referenced files. My question is: is there a way not to hard coding the reference path in source code? Are there things like preprocessor or Macro in TypeScript, or could I use the project system to help resolving dependency, rather than hard coding them in source code?

Original source