Description
TypeScript Version: 4.0.0-dev.20200429
Search Terms:
function name
shorthand function name missing
exported function missing name
Code
cat > test.ts <<"EOF"
var test1 = () => {};
export var test2 = () => {};
console.log(`name for test1 = "${test1.name}"`);
console.log(`name for test2 = "${test2.name}"`);
EOF
npx -p typescript@next tsc test.ts --module umd
node test.js
Expected output: (And also the output from node@latest running the .ts file with .mjs extension)
name for test1 = "test1"
name for test2 = "test2"
Actual output:
name for test1 = "test1"
name for test2 = ""
Also the compiler complains about .name
property. Isn't the .name property supported at all on shorthand functions?
test.ts:3:40 - error TS2339: Property 'name' does not exist on type '() => void'.
Playground Link:
Couldn't get the Playground Link with an export
to run in the browser.. :/
Related Issues: #5611 seems similar, but this case is simpler and should be able to be solved I believe.
Generated code seems to be something like:
// ...
var test1 = function () { };
exports.test2 = function () { };
// ...
Should probably be either
var test1 = function () { };
var test2 = function () { };
exports.test2 = test2
Or
var test1 = function () { };
exports.test2 = function test2() { };