2
votes

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.

1

1 Answers

2
votes

You can type your worker variable:

var worker: IWorker = require('worker');

This will provide type-checking on the worker variable.