You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
While transpiling TypeScript code, TSC preserves the order while SWC doesn't and just puts all the imports to the top.
It can cause errors in some situations. The code below is the minimum reproduction of the problem I've faced.
I'm not sure if it's just an implementation detail of TSC or a spec but the resulting code is different and it can causes errors.
To follow the specification, import statements should be hoisted and tsc is simply doing wrong thing.
Official typescript compiler has a PR to fix the wrong behavior. (See microsoft/TypeScript#39764)
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.
Describe the bug
While transpiling TypeScript code, TSC preserves the order while SWC doesn't and just puts all the imports to the top.
It can cause errors in some situations. The code below is the minimum reproduction of the problem I've faced.
I'm not sure if it's just an implementation detail of TSC or a spec but the resulting code is different and it can causes errors.
Input code
parent.ts
child.ts
Config
Expected behavior
require()
statement should be at the same place whereimport
statement was at(at least that's what TSC does)
Version
The version of @swc/core: 1.2.58
Additional context
Since the problem can be solved by using
require()
instead of import, fixing this issue isn't that needed.The text was updated successfully, but these errors were encountered: