Skip to content

Let a closure capture a destructured const declared after it - #4056

Open
ctate wants to merge 1 commit into
mainfrom
ctate/uisdk-later-destructured-binding
Open

ctate wants to merge 1 commit into
mainfrom
ctate/uisdk-later-destructured-binding

Conversation

@ctate

@ctate ctate commented Nov 22, 2026

Copy link
Copy Markdown
Collaborator
  • A closure created above a destructuring declaration can capture its targets, with the same temporal dead zone check as a plain const
  • Part of compiling the UI SDK popup and Slider; adds a corpus test

@vercel

vercel Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
scriptc Ready Ready Preview, v0 Nov 22, 2026 3:15pm UTC

if (idx < entry.index || entry.ctx === lowerer.ctx || entry.ctx.tdzPredeclared.has(symbol))
return false;
let type = lowerer.irTypeOf(decl.name);
let type = lowerer.irTypeOf(nameNode);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forward-capturing an array-destructured element uses its non-optional checker type, causing destructuring a missing element to throw instead of initializing the binding to undefined.

Fix on Vercel

This branch was successfully deployed

1 active deployment
Preview — 553839ed Deployed Nov 22, 2026 by vercel[bot]
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 this pull request may close these issues.

1 participant