I am facing a weird issue. In my (lets say) a.ts
I have -
/// <reference path="../typings/mocha/mocha.d.ts" />
/// <reference path="../typings/should/should.d.ts" />
import should = require('should');
import something_else = require('../something-else');
Now when I compile using command -
tsc -m commonjs --outDir "./build" "src/test/a.ts"
My generated javascript is not having require
for should
-
/// <reference path="../typings/mocha/mocha.d.ts" />
/// <reference path="../typings/should/should.d.ts" />
var service_manager = require('../routes/service-manager');
This seems like a bug in typescript compiler, but I may be doing it incorrectly. Or if there is some workaround, please share.
As the comment by Eric Nicholson, just
require
withoutimport
.Besides, those
reference path
would be bundled attypings/tsd.d.ts
by default and no need to write in individual file.It does that because you are not using it. It will stick as soon as you you actually use the
should
variable. e.g.Reason: It allows you to use type information on its own without taking a runtime dependency on
require('should')
. It also allows you to do lazy loading in AMD scenarios.