javascript - Typescript error "Cannot find name" -


i trying use big.js library, definition here.

now, line works:

const constant_1 = new big(0); 

whilst line:

const constant_2 : big = new big(0); 

causes error:

error ts2304: cannot find name 'big'. 

what's problem?

look @ first 1 implicitly typed as:

bigjslibrary.bigjs

problem

the reason doesn't work...

const constant_2: big = new big(0); 

...is because big defined variable in definition file—not type:

declare var big: bigjslibrary.bigjs; 

solution

if wish use explicit typing need reference created type of constructor...

const constant_2: bigjslibrary.bigjs = new big(0); 

...as shown in definition file here:

interface bigjs_constructors {     new (value: number): bigjs;     // etc... } 

Comments