Skip to content Skip to sidebar Skip to footer

Why Is Typescript Compiler Omitting 'should.js' Import In Generated Javascript?

I am facing a weird issue. In my (lets say) a.ts I have - /// /// i

Solution 1:

It does that because you are not using it. It will stick as soon as you you actually use the should variable. e.g.

///<reference path="../typings/mocha/mocha.d.ts" />///<reference path="../typings/should/should.d.ts" />

import should = require('should');
var persist = should; 

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.

Solution 2:

As the comment by Eric Nicholson, just require without import.

require('should');
//use should

Besides, those reference path would be bundled at typings/tsd.d.ts by default and no need to write in individual file.

Post a Comment for "Why Is Typescript Compiler Omitting 'should.js' Import In Generated Javascript?"