Skip to content

Arrow function name is not defined. #15871

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mpodlasin opened this issue May 16, 2017 · 2 comments
Closed

Arrow function name is not defined. #15871

mpodlasin opened this issue May 16, 2017 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@mpodlasin
Copy link

Hi everyone. Afaik arrow functions should have names copied from names of variables they are assigned to at creation time.

This is a problem for example with stateless React components, where function name is a basis for component name (which now in react development tools are seen as Unknown).
Babel sets arrow function names properly.

Code

const x = (a: number, b: number) => a + b;
console.log(x.name);

Expected behavior:
Compiles to

const x = function x(a, b) { return a + b; };
console.log(x.name);

Prints "x".

Actual behavior:
Compiles to

const x = function (a, b) { return a + b; };
console.log(x.name);

Prints undefined.

@kitsonk
Copy link
Contributor

kitsonk commented May 16, 2017

Dupe of #6433

@mpodlasin
Copy link
Author

@kitsonk thanks. could not find one.

@DanielRosenwasser DanielRosenwasser added the Duplicate An existing issue was already created label May 16, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants