Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exporting declaration after function invocation misses semi #824

Open
erikmueller opened this issue Jan 29, 2024 · 0 comments · May be fixed by #829
Open

Exporting declaration after function invocation misses semi #824

erikmueller opened this issue Jan 29, 2024 · 0 comments · May be fixed by #829

Comments

@erikmueller
Copy link

I am using sucrase to transpile some jest tests and came across a (typescript) file containing a function invocation followed by an export declaration.

Since the export declaration is wrapped into parens during transpilation, it seems the resulting code created a higher order function as it tries to call the result of the invocation with the wrapped export (as there are no semicolons).

const fn = () => ({ key: { nested: 1 } })

const data = fn()
export const { nested } = data.key

results in

"use strict";Object.defineProperty(exports, "__esModule", {value: true});const fn = () => ({ key: { nested: 1 } })

const data = fn()
( { nested: exports.nested } = data.key)

which would lead to const data = fn()(({ nested: exports.nested } = data.key)) and fail for a couple of reasons.

@magic-akari magic-akari linked a pull request Feb 21, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant