Files
codegraph/__tests__
Colby MchenryandClaude Opus 5.5 ada1445458 fix(ts): a qualified type's last name is a member of what its qualifier names, not any declaration of that name (#2739)
Both extractors record the last name of a qualified type alone, so
`React.ReactNode` reached name matching as `ReactNode` and bound by word:
outline's 197 `React.ReactNode` annotations linked to its own editor
`class ReactNode`, excalidraw's `TChat.ChatMessage` to a `ChatMessage`
component, signoz's `EQueryType.CLICKHOUSE` to another enum's member, and
outline's `UnfurlResourceType.Group` to the `Group` model the file imports.
PR #2736 left that name to name matching on purpose.

A TypeScript `references` ref written after a qualifier now resolves
through the qualifier, ahead of the framework, import and name strategies:
- an import: the module's export (`import * as T`, through barrels and the
  repository's own `declare module` blocks), or the member of the enum,
  class or namespace a named or default import binds;
- a declaration of the file's own, in the innermost namespace around the
  reference that declares it, else at the top level: an enum's or a
  class's `::` member, or a member of a namespace block;
- otherwise a namespace the project declares global (`Express.User` in a
  `declare global` block).
A package from outside the repository, which no manifest of the importing
file's declares as its own and no `declare module` block declares, and a
global the project doesn't declare, link nothing. An import this resolver
can't follow but no manifest declares as a dependency (zod's own tests'
`import * as z from "zod/v3"`, through the package's `exports`), an
`import X = ns.Y` alias, and a name written after an expression
(`import('./x').T`) keep the old strategies.

The index holds no node for a TypeScript namespace, and its members are
indexed by their bare names, so ambient-modules gains scanNamespaceBlocks:
every `namespace A.B { … }` block with its full name and whether it is
global, read from the same tokens as the module blocks.

Validated on 18 TypeScript repos (13 React apps plus zod, vben, mealie,
prometheus's web UI and fastapi-template), main 2c4a16d0 against this fix,
every changed site checked with the TypeScript checker in a program over
each file's tsconfig and the repository's declaration files, without
node_modules:
- 300 qualified types move from a wrong declaration to the member
  TypeScript binds (zod 224, outline 39, excalidraw 23, signoz 10,
  mastodon 3, prometheus 1);
- 297 lose a wrong link and link nothing, where TypeScript binds nothing
  of the project, a package's member (outline 254, signoz 32, bbb 8,
  mastodon 3);
- 43 unresolved ones now link the member (outline 28, zod 9, signoz 6);
- 1966 keep their target, now resolved through the qualifier;
- next-saas, proshop, t3-turbo, minimal-kit, matx, berry, mantis,
  bulletproof, fastapi-template and mealie are byte-identical;
- index time is unchanged (125 s before, 120 s after, all 18 repos).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 09:48:45 +00:00
..