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

Default value not preserved in TypeScript exported binding #8025

Closed
magic-akari opened this issue Sep 29, 2023 · 1 comment · Fixed by #8029
Closed

Default value not preserved in TypeScript exported binding #8025

magic-akari opened this issue Sep 29, 2023 · 1 comment · Fixed by #8029
Assignees
Labels
Milestone

Comments

@magic-akari
Copy link
Member

magic-akari commented Sep 29, 2023

Describe the bug

Default values are lost when converting TS namespace export bindings.

Input code

namespace Foo {
  export let { a = 1 } = {};
  export const { b = 2 } = {};
}

console.log(Foo.a);
console.log(Foo.b);

Config

{
  "jsc": {
    "parser": {
      "syntax": "typescript"
    },
    "target": "es2022"
  },
  "module": {
    "type": "commonjs"
  },
  "isModule": true,
  "minify": false,
}

Playground link

playground

SWC Info output

N/A

Expected behavior

log 1 and 2

Actual behavior

"use strict";
var Foo;
(function(Foo) {
    ({ a: Foo.a } = {});
    const { b = 2 } = { b: Foo.b } = {};
})(Foo || (Foo = {}));
console.log(Foo.a);
console.log(Foo.b);

log undefined

Version

1.3.90

Additional context

No response

@kdy1 kdy1 added this to the Planned milestone Sep 29, 2023
@kdy1 kdy1 self-assigned this Sep 29, 2023
kdy1 pushed a commit that referenced this issue Sep 29, 2023
@kdy1 kdy1 modified the milestones: Planned, v1.3.91 Oct 1, 2023
@swc-bot
Copy link
Collaborator

swc-bot commented Oct 31, 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.

@swc-project swc-project locked as resolved and limited conversation to collaborators Oct 31, 2023
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