interface ExampleType {
[key: string]: string | (() => string);
}
const testObj: ExampleType = {
firstName: "Peter",
lastName: "Parker",
gender: "male",
getFullName: () => "I am Peter Parker",
};
const { firstName, lastName, getFullName } = testObj;
console.log(getFullName()); // this does not works
if (typeof getFullName === "function") {
console.log(getFullName()) // this works
}
I am getting following error: **This expression is not callable. Not all constituents of type 'string | (() => string)' are callable. Type 'string' has no call signatures. **