Error TS2339: Property 'name' does not exist on type 'Function'

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Error TS2339: Property 'name' does not exist on type 'Function'



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?




1 Answer
1



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 ES6 you should see it.


lib.es6.d.ts


--target ES6






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

Creating a leaderboard in HTML/JS