Hoisted function declarations should be assigned to exports
before any require
calls
#39853
Labels
Bug
A bug in TypeScript
Fix Available
A PR has been opened for this issue
Has Repro
This issue has compiler-backed repros: https://aka.ms/ts-repros
Rescheduled
This issue was previously scheduled to an earlier milestone
Milestone
TypeScript Version: 4.2.0-beta
Search Terms:
Code
Workbench Repro
Expected behavior:
The
exports.*
assignment should be done immediately after__esModule
, just like how Babel does it.Actual behavior:
The exports assignment is performed after the function declaration, which causes behaviour differences between native ES modules (where hoisted function declarations are initialised before any code begins executing) and transpiled CommonJS modules (where hoisted function declarations are added to the
exports
object afterrequire(…)
calls)Playground Link: a.js, b.js
Related Issues: #37093
The text was updated successfully, but these errors were encountered: