Skip to content

Resolve JSDoc '#' links to instance members - #65580

Closed
5 (tydavid5) wants to merge 1 commit into
microsoft:mainfrom
tydavid5:fix/jsdoc-hash-link-instance-65507
Closed

5 (tydavid5) wants to merge 1 commit into
microsoft:mainfrom
tydavid5:fix/jsdoc-hash-link-instance-65507

Conversation

@tydavid5

Copy link
Copy Markdown

Fixes #65507

In TypeScript 6, a JSDoc link written as Foo#member resolved to the instance member, while Foo.member resolved to the static member. The Go port lost that distinction: its parser turns both separators into the same QualifiedName, so the checker resolved both links through the static members first. The parser now records a '#' separator with a node flag, and the checker treats a flagged name as an instance member reference, looking it up on the class prototype instead of resolving it as an entity name. Dot links, plain links, and links on interfaces are unchanged, and a '#' link on a namespace still resolves to nothing, as it did in TypeScript 6, since namespaces have no declared type to look the member up on.

Tests: a new compiler test case covers the reported code, and new checker tests assert the resolved symbol for the reported case plus instance-only, static-only, interface, method, missing member, plain link, namespace, see tag, namespace-qualified, and chained '#' cases. The new tests fail with the fix reverted and pass with it.

Fixes microsoft#65507

In TypeScript 6, a JSDoc link written as Foo#member resolved to the instance member, while Foo.member resolved to the static member. The Go port lost that distinction: its parser turns both separators into the same QualifiedName, so the checker resolved both links through the static members first. The parser now records a '#' separator with a node flag, and the checker treats a flagged name as an instance member reference, looking it up on the class prototype instead of resolving it as an entity name. Dot links, plain links, and links on interfaces are unchanged, and a '#' link on a namespace still resolves to nothing, as it did in TypeScript 6, since namespaces have no declared type to look the member up on.

Tests: a new compiler test case covers the reported code, and new checker tests assert the resolved symbol for the reported case plus instance-only, static-only, interface, method, missing member, plain link, namespace, see tag, namespace-qualified, and chained '#' cases. The new tests fail with the fix reverted and pass with it.
Copilot AI balanced review requested due to automatic review settings November 19, 2026 12:58
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Nov 19, 2026
@typescript-automation typescript-automation Bot added the For Backlog Bug PRs that fix a backlog bug label Nov 19, 2026

Copilot AI left a comment

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.

🟡 Changes recommended

JSDoc member resolution remains API-call-order dependent because cached static symbols bypass the guard, and the new flag is missing from generated API enums.

2 open issues
What changed in this PR

This PR addresses #65507 by distinguishing JSDoc Foo#member links from Foo.member, restoring instance-member resolution in the Go compiler.

Changes:

  • Add an AST flag and helper to preserve # separators during parsing.
  • Route flagged links through instance-member resolution in the checker.
  • Add checker regression tests and a conformance case with baselines.
File Description
tsc/​testdata/​tests/​cases/​conformance/​jsdoc/​jsdocLinkTag10.ts Adds the reported static-versus-instance example.
tsc/​testdata/​baselines/​reference/​conformance/​jsdocLinkTag10.types Records expected types.
tsc/​testdata/​baselines/​reference/​conformance/​jsdocLinkTag10.symbols Records declaration symbols.
tsc/​testdata/​baselines/​reference/​conformance/​jsdocLinkTag10.js Records JavaScript output.
tsc/​internal/​parser/​jsdoc.go Marks names parsed with #.
tsc/​internal/​checker/​checker.go Adds instance-member resolution for flagged links.
tsc/​internal/​checker/​checker_test.go Tests link targets and edge cases.
tsc/​internal/​ast/​utilities.go Adds the flagged-name predicate.
tsc/​internal/​ast/​nodeflags.go Defines the JSDoc member-name flag.

Review effort: Balanced

Comment on lines +32841 to +32842
if !(isJSDoc && ast.IsJSDocMemberName(name)) {
c.checkQualifiedName(name, CheckModeNormal)
NodeFlagsPossiblyContainsDeprecatedTag NodeFlags = 1 << 26 // Set during parse if comment text contains '@deprecated'; must confirm via JSDoc lookup
NodeFlagsUnreachable NodeFlags = 1 << 27 // If node is unreachable according to the binder
NodeFlagsReparserTransformedLiteral NodeFlags = 1 << 28 // If node was transformed during parsing, making its' naive text source not match the AST
NodeFlagsJSDocMemberName NodeFlags = 1 << 29 // If a QualifiedName was parsed from a JSDoc link name using the '#' separator (Foo#member), marking it as an instance member reference rather than a static member reference
@github-project-automation github-project-automation Bot moved this from Not started to Done in PR Backlog Nov 19, 2026
@RyanCavanaugh

Copy link
Copy Markdown
Member

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.

JSDoc # link resolution behavior broke in TS 7

3 participants