Better file reference for typescript -
i’m new typescript , trying setup unit tests typescript code base. problem code depends on other's work , these references done in form of hard coded relative paths “......\somefile.d.ts”. when come unit test, want fake out of dependencies don’t know how make typescript take fakes instead of hard coded referenced files.
my question is: there way not hard coding reference path in source code? there things preprocessor or macro in typescript, or use project system resolving dependency, rather hard coding them in source code?
check out grunt-ts reference file generation : https://github.com/basarat/grunt-ts#reference-file-generation
what can have seperate targets, 1 dev , 1 test :
dev: { src: ["app/**/*.ts", "!app/**/*.spec.ts"], // exclude spec files reference: "./app/reference.ts", out: 'app/out.js', }, test: { src: ["app/**/*.ts"], // include files reference: "./app/reference.ts", out: 'app/out.js', },
now reference app/reference.ts
from files. when want run tests, build tests, when want release / dev build dev.
also check out video tutorial : http://www.youtube.com/watch?v=0-6vt7xge4y&hd=1
Comments
Post a Comment