I have the following function:
export function output(functions: Function[], inputs: unknown[]) {
for (let func of functions) {
console.log(`=== ${func.name} ===`);
for (let input of inputs) {
console.log(`"${input}"\t-> ${func(input)}`);
}
console.log();
}
}
It works fine. However the tsc compiler complains on this line:
console.log(`=== ${func.name} ===`);
Saying:
Error TS2339: Property 'name' does not exist on type 'Function'.
What is causing the issue?
I was able to reproduce this problem. It looks like the lib.d.ts file that defines the interface for Function doesn't have "name" as a property.
See Typescript Issue 6623, which has a workaround.
The name property on interface Function is defined in
lib.es6.d.ts. If you compile with--target ES6you should see it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With