I am new to typescript. While I was learning signatures, I came across this error. I declared a type with function as shown here. It was working fine when I had only the function, later I introduced an additional property to that type, and I don't how to use the type after that.
type GreetFunction = {
(x: string): void;
};
function greeter(fn: GreetFunction) {
fn("Hello");
}
function printToConsole(a: string) {
console.log(a);
}
greeter(printToConsole); //This is working fine ( Converting to js file )
But the below code is not converting and giving errors.
type GreetFunction = {
desc: string;
(x: string): void;
};
function greeter(fn: GreetFunction) {
fn("Hello");
}
function printToConsole(a: string) {
console.log(a);
}
greeter(printToConsole); //This is line is giving error