Directly exporting an (arrow) function prevents it from being named #39819
Labels
Fix Available
A PR has been opened for this issue
Needs Investigation
This issue needs a team member to investigate its status.
Milestone
When using the
export const Var = () => console.log('stuff')
, the result code prevents the function from using the name of the variable, because it directly usesexport.Var = () => console.log('stuff')
(no variable on the left side to take the name from).TypeScript Version: 3.7.2 and 4.0.0-dev.20200729
Search Terms:
const export, export variable, export function
Code
yields (testable on the browser -if you declare exports
{}
before pasting it on the console- or node):The problem is that
exports.Foo
will remain as an anonymous function. In node and in the browser it printsFoo name is
.Expected behavior:
I was expecting the variable to remain, so that node or the browser uses the variable name for naming the arrow function:
This outputs on node and the browser:
Foo name is Foo
Actual behavior:
The (arrow) functions that are exported don't get any naming on the browser/node (they remain anonymous).
Playground Link:
Showing the compilation
I'm adding a js link, as I get errors when trying to run because of the "exports"
Running the compilation
Running proposed compilation
Related Issues:
#14127
#6433
I have a branch with the suggested changes, but didn't send a PR because there isn't an associated issue in the
Backlog
milestone.I can send a PR with it and continue working on it if it is a valid change.
https://github.com/josejulio/TypeScript/tree/export-functions
The text was updated successfully, but these errors were encountered: