Reputation: 82590
I am using Typescript 0.9.1.1 and I seem to be getting an error with this simple problem:
function doSomething(): void {
console.log("Printing something");
}
window.setTimeout(() => {
doSomething();
}, 3000);
It says that I have an Unresolved Function or Method setTimeOut()
. I looked into the Typescript lib.d.ts file, and this is what I found:
declare function setTimeout(expression: any, msec?: number, language?: any): number;
From this piece of documentation on MDN, I can also say that I am calling it right. So, why is TypeScript giving me issues?
This is what my lib.d.ts file looks like:
Upvotes: 0
Views: 1967
Reputation: 251242
I'm using 0.9.1.1 and the signature is different to the one you have posted:
declare function setTimeout(handler: any, timeout?: any, ...args: any[]): number;
And everything compiles fine to:
function doSomething() {
console.log("Printing something");
}
window.setTimeout(function () {
doSomething();
}, 3000);
Where are you looking for that lib.d.ts?
In any case, you shouldn't get the error because the signature you posted only requires the expression (any) and you are supplying an msec (number) of the correct type - so your call looks compatible with that.
Upvotes: 1