I have an interface below with call signature inside it
type MyTest = {
description: string;
(x: number): number;
};
But I don't know how to create instance of this interface in TypeScript. I have tested 3 solution below and nothing worked
const test1: MyTest = {
description: 'My Name' // error: Type '{ description: string; }' provides no match for the signature '(x: number): number'.
}
const test2: MyTest = (myNumberInput: number) => myNumberInput.toString(); // error: Property 'description' is missing in type '(myNumberInput: number) => string' but required in type 'MyTest'.
const test3: MyTest = {
description: 'My Name', // error: Type '{ description: string; }' has no call signatures.
(myNumberInput: number) => myNumberInput.toString() // error: Cannot find name 'myNumberInput'. + 'number' only refers to a type, but is being used as a value here.
}
Please give me an instruction for this problem. Thank a lot and have nice day!