Consider the following code snippet:
type T = (x: number) => boolean;
let fn = function(a: string, b: boolean, c: T){};
fn('yes', true, ()=> {
});
Unfortunately, this code will not compile. The goal is to cast the anonymous function to a specific type like this:
fn('yes', true, ()=> {
} as T);
Alternatively, you may attempt to do it like this:
fn('yes', true, <T>()=> {
});
However, attempting these methods results in an error message:
Cannot find name "as"
Is there a way to cast the function to another type directly within the code?