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
Inside a namespace, referring to an exported property in the namespace generally works because it gets emitted as a var binding. However, when the export is defined using destructuring syntax, there are no such bindings and so any references to exports declared that way fail at runtime.
Either emit a var binding for each destructured property, or rewrite the reference to the exported property from args to cli.args (tsc does the latter).
yseymour
changed the title
References to destructured exports in namespaces don't get rewritten
References to destructured exports in namespaces aren't resolvable at runtime
May 26, 2023
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
Inside a namespace, referring to an exported property in the namespace generally works because it gets emitted as a
var
binding. However, when the export is defined using destructuring syntax, there are no such bindings and so any references to exports declared that way fail at runtime.Input code
Config
Playground link
https://play.swc.rs/?version=1.3.60&code=H4sIAAAAAAAAA0XMQQqDMBCF4b2neEuF0guUrtx6iWE62oCZhEwEQXL3xkZw9%2BDxf7LHkDKUvFgkFvDqcHSAtIODWsaBELOr8wFKi6HgjUjJZAzek34mp9IPrzubN%2BUzQNq0H%2F4gLotbUoWTetrXzbm1pSs%2FQPhzc48AAAA%3D&config=H4sIAAAAAAAAA22Quw6DMAxF934F8tyhYuzclY%2BwgkFB5CHbSEWIf294hFLRLfZ1zr32dCsK6MTAs5jSMxURWYiPOnVk9Irv1AEdI4lhGxXuWVVZpAZ7oaNXkwmMGliSpDzQKsybDorcki48kvJRljsL%2BhCEflmgjF6awO4cqKcWzfjKJrvH1b0ixRoV%2F4Vw1ttmPFNNcJFJ5LKNQ9%2F2R7CNcttJ4EI9rOJ%2BvuVEy2qJ5oLvBL6T2fGgg5Uqf18Dzh87elJPjwEAAA%3D%3D
Expected behavior
Either emit a
var
binding for each destructured property, or rewrite the reference to the exported property fromargs
tocli.args
(tsc
does the latter).Actual behavior
At runtime,
ReferenceError: args is not defined
Version
1.3.60
Additional context
Here's the tsc output, for comparison.
I had a quick look but only found #3073 as a possible related issue, which was quite a while ago.
The text was updated successfully, but these errors were encountered: