97
rated 0 times
[
99]
[
2]
/ answers: 1 / hits: 16692
/ 4 Years ago, thu, july 9, 2020, 12:00:00
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. **
More From » typescript