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

swc produces an invalid syntax file (export const txt) #1508

Closed
gaeulbyul opened this issue Mar 28, 2021 · 1 comment · Fixed by #1516
Closed

swc produces an invalid syntax file (export const txt) #1508

gaeulbyul opened this issue Mar 28, 2021 · 1 comment · Fixed by #1516
Assignees
Labels
Milestone

Comments

@gaeulbyul
Copy link

Description

When I compile this code with swc, It emits const txt; but that's an invalid syntax.

Expected behavior

I tested same code with Sucrase, Babel, and esbuild. All of these compilers produce empty code. so maybe swc should also follow this behavior?

Input code

(TypeScript. code from: https://github.com/gaeulbyul/RedBlock/blob/52d4bef6eb52bf27856660ddae188cc3a279cdc6/src/scripts/types.d.ts#L11-L13 )

declare namespace twttr {
  export const txt: typeof import('twitter-text')
}

Output

var twttr;
(function(twttr1) {
    const txt; // <------------ syntax error!
    twttr1.txt = txt;
})(twttr || (twttr = {
}));

Config

{
  "jsc": {
    "parser": {
      "syntax": "typescript"
    },
    "target": "es2019"
  }
}

Version

@swc/cli: 0.1.36
@swc/core: 1.2.51
@kdy1 kdy1 added this to the v1.2.52 milestone Mar 29, 2021
@kdy1 kdy1 self-assigned this Mar 30, 2021
kdy1 added a commit to kdy1/swc that referenced this issue Mar 30, 2021
kdy1 added a commit to kdy1/swc that referenced this issue Mar 30, 2021
@kdy1 kdy1 mentioned this issue Mar 30, 2021
6 tasks
kdy1 added a commit that referenced this issue Mar 30, 2021
swc_ecma_ast:
 - Support TypeScript 4.3. (#1517)

swc_ecma_parser:
 - Support new syntaxes from typescript 4.3. (#1517) 

swc_ecma_transforms_compat:
 - Fix '\\`' in template literals. (#1488)
 - `classes`: Fix super calls. (#1490)

swc_ecma_transforms_module:
 - Respect `esModuleInterop` for dynamic imports. (#1480)

swc_ecma_transforms_typescript:
 - `strip`: Remove `declare`-d namespaces. (#1508)
@swc-bot
Copy link
Collaborator

swc-bot commented Oct 25, 2022

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.

@swc-project swc-project locked as resolved and limited conversation to collaborators Oct 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging a pull request may close this issue.

3 participants