Skip to content

Conversation

@Renegade334
Copy link
Contributor

@Renegade334 Renegade334 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:

declare using a: null; // error
declare global {
    using b: null; // not an error
}
namespace N {
    export using c = null; // error
    export declare using d: null; // error
}
declare namespace N {
    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-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label May 29, 2025
@Renegade334 Renegade334 marked this pull request as ready for review May 29, 2025 10:52
@jakebailey jakebailey merged commit 1e24945 into microsoft:main Jun 6, 2025
32 checks passed
@Renegade334 Renegade334 deleted the disallow-ambient-using branch June 6, 2025 21:02
@microsoft microsoft locked as resolved and limited conversation to collaborators Dec 9, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

For Uncommitted Bug PR 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