Skip to content

Support @deprecated on namespace aliases (ImportEqualsDeclaration)#62904

Closed
thromel wants to merge 1 commit intomicrosoft:mainfrom
thromel:fix/deprecated-namespace-alias
Closed

Support @deprecated on namespace aliases (ImportEqualsDeclaration)#62904
thromel wants to merge 1 commit intomicrosoft:mainfrom
thromel:fix/deprecated-namespace-alias

Conversation

@thromel
Copy link
Copy Markdown

@thromel thromel commented Dec 16, 2025

Fixes #62340

Problem

When using @deprecated on a namespace alias like:

export namespace JSX {
    /** @deprecated */
    export import Bar = example.Bar;
}

Accessing JSX.Bar as a type did not show a deprecation warning, even though the alias itself is marked as deprecated.

Root Cause

In checkTypeReferenceOrImport, the resolvedSymbol is the resolved target of the alias (e.g., example.Bar), not the alias symbol itself. Since the alias (the ImportEqualsDeclaration) was not being checked, its @deprecated JSDoc was ignored.

Fix

Added code to also resolve the entity name without resolving aliases (dontResolveAlias: true) and check if the alias symbol itself is deprecated using isDeprecatedSymbol().

Test

Added tests/cases/fourslash/jsdocDeprecated_namespaceAlias.ts covering:

  1. Direct type alias with @deprecated (already worked)
  2. ImportEqualsDeclaration with @deprecated (the bug being fixed)
  3. ImportEqualsDeclaration aliasing a deprecated type (already worked)

Fixes microsoft#62340

When a namespace re-exports a type using `export import Bar = example.Bar`
with a `@deprecated` JSDoc comment, the deprecation warning was not being
reported when accessing `JSX.Bar` as a type.

The issue was that in `checkTypeReferenceOrImport`, the `resolvedSymbol`
is the resolved target of the alias, not the alias itself. To detect
deprecation on the alias, we now also resolve the entity name without
resolving aliases and check if the alias symbol itself is deprecated.
@github-project-automation github-project-automation bot moved this to Not started in PR Backlog Dec 16, 2025
@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Dec 16, 2025
@github-project-automation github-project-automation bot moved this from Not started to Done in PR Backlog Mar 24, 2026
@typescript-bot
Copy link
Copy Markdown
Collaborator

With 6.0 out as the final release vehicle for this codebase, we're closing all PRs that don't fit the merge criteria for post-6.0 patches. If you think this was a mistake and this PR fits the post-6.0 patch criteria, please post to the 6.0 iteration issue with details (specifically, which PR and which patch criteria it satisfies).

Next steps for PRs:

  • For crash bugfixes or language service improvements, PRs are currently accepted at the typescript-go repo
  • Changes to type system behavior should wait until after 7.0, at which point mainline TypeScript development will resume in this repository with the Go codebase
  • Library file updates (lib.d.ts etc) continue to live in this repo or the DOM Generator repo as appropriate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Backlog Bug PRs that fix a backlog bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Support @deprecated marker on namespace aliases

2 participants