Reputation: 953
I am loading a non-typescript amd module (written in javascript, not compiled from ts) inside a typescript module using require:
var worker = require('worker');
the worker module exports several constructor-functions.
now I want to make some type definitions (for example as the backbone.d.ts)
module WorkerModule {
interface IResult {
amount(): number;
}
interface IWorker {
work();
getResult(): IResult;
}
interface OtherWorker extends IWorker {
workMore();
}
}
How can I tell TSC that worker is a WorkerModule. thanks for any help.
Upvotes: 2
Views: 764
Reputation: 250882
You can type your worker variable:
var worker: IWorker = require('worker');
This will provide type-checking on the worker
variable.
Upvotes: 2