This works:
function test(msg:string){
console.log(msg);
}
setTimeout(test, 1000, ["Hi!"];
...in that it will print out "Hi!" to the console after one second.
This also works:
function test(){
console.log("Hi!");
}
function callTest(next: () => void){
next();
}
callTest(test);
In that it also prints out "Hi!" to the console.
The following results in the error "TypeError: next is not a function". Why?
function test(){
console.log("Hi!");
}
function callTest(next: () => void){
next();
}
setTimeout(callTest, 1000, [test]);
It sure looks like a function to me! If the 1st code snippet works it shows that I have the form generally right to use setTimeout and send parameters to the callback, and the 2nd code snippet shows that this is the correct form to call a function passed in as a parameter - why isn't my use of setTimeout in the 3rd code snippet working?