Reputation: 185
I'm just trying to get Typescript 2 to use a local definition file provided by me, for a javascript library I installed through NPM.
First, I installed MockDate:
npm i --save-dev mockdate
Then, I attempted to import it via
import MockDate from 'mockdate'
Only to be told it couldn't find it. From here, I've created local definitions, I've declare module 'mockdate'
, I've done
declare module MockDate {
function set(date: Date): void
}
at the top of the file- and no matter what I do, I continue to receive(from atom-typescript
) "Cannot find module 'mockdate'".
Upvotes: 4
Views: 876
Reputation: 11
Triple-Slash Directives code sample
Upvotes: 1
Reputation: 4035
Almost there! You need to write:
declare module 'mockdate' {
function set(date: Date): void
}
And make sure this d.ts file is picked up by your tsconfig.
Upvotes: 3