Skip to content

Conversation

@Renegade334
Copy link
Contributor

@Renegade334Renegade334 commented May 29, 2025

Since it first supported ERM, the compiler has shunned ambient using: declare [await] using is invalid, and variables appearing in the declaration emit are converted to const.

However, there is a blind spot in the checker, and that is when a variable declaration occurs in already-ambient context:

declareusing a: null;// error declare global { using b: null;// not an error}namespaceN{export using c=null;// error export declareusingd: null;// error} declare namespaceN{ using e: null;// not an error}

Technically this doesn't apply to await using, as the checker will already complain about an invalid await context, but this PR adds errors on both for consistency.

Closes#61752.

@typescript-bottypescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label May 29, 2025
@Renegade334Renegade334 marked this pull request as ready for review May 29, 2025 10:52
@jakebaileyjakebailey merged commit 1e24945 into microsoft:mainJun 6, 2025
32 checks passed
@Renegade334Renegade334 deleted the disallow-ambient-using branch June 6, 2025 21:02
@microsoftmicrosoft locked as resolved and limited conversation to collaborators Dec 9, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

For Uncommitted BugPR for untriaged, rejected, closed or missing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

declare namespace{using ... } generates incorrect dts

3 participants

@Renegade334@jakebailey@typescript-bot