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

TypeScript: Object deconstruction with alias and default value does not work #30766

Closed
kostia1st opened this issue Nov 1, 2021 · 2 comments · Fixed by #31816
Closed

TypeScript: Object deconstruction with alias and default value does not work #30766

kostia1st opened this issue Nov 1, 2021 · 2 comments · Fixed by #31816
Assignees
Labels
bug Issue was opened via the bug report template. SWC Related to minification/transpilation in Next.js.

Comments

@kostia1st
Copy link

kostia1st commented Nov 1, 2021

What version of Next.js are you using?

12.0.2

What version of Node.js are you using?

16.4.0

What browser are you using?

Edge, Chrome

What operating system are you using?

Windows 11

How are you deploying your application?

next dev

Describe the Bug

Here's a TypeScript code snippet

  const value = { ho: [1, 2] };
  const { ho: hey = [] } = value;
  console.log(hey);

Output is []

Must be [1, 2]

Once you remove the "default value" or aliasing - it works normally.

tsconfig.json -> compilerOptions -> "target": "es5", "module": "commonjs", "lib": ["dom", "dom.iterable", "esnext"]

Reverting back to "next": "11.1.2" immediately fixes the issue.

Expected Behavior

Should be deconstructing objects properly, assigning the default value only when the provided one is not defined.

I can just imagine it's somehow connected with the new Rust compiler.

To Reproduce

See above

@kostia1st kostia1st added the bug Issue was opened via the bug report template. label Nov 1, 2021
@kostia1st kostia1st changed the title Object deconstruction with alias and default value does not work TypeScript: Object deconstruction with alias and default value does not work Nov 1, 2021
@timneutkens timneutkens added the SWC Related to minification/transpilation in Next.js. label Nov 2, 2021
@timneutkens timneutkens added this to the 12.0.x milestone Nov 2, 2021
@kdy1 kdy1 self-assigned this Nov 4, 2021
@styfle styfle modified the milestones: 12.0.x, 12.0.4 Nov 5, 2021
@timneutkens timneutkens removed this from the 12.0.5 milestone Nov 17, 2021
@kostia1st
Copy link
Author

kostia1st commented Nov 23, 2021

From my perspective this issue is critical - because it does not yell to the developer that something's not working, instead it silently works improperly.

If I had my billing implemented in TS/node.js, and poor E2E-testing applied, I'd be having 3 weeks of corrupt data by now. Cannot imagine someone's using version 12 of next.js in production right now.

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. SWC Related to minification/transpilation in Next.js.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants