Skip to content

fix(deps): pin typescript below 7.x and warn loudly when an incompatible version is detected - #2332

Merged
carlos-alm merged 2 commits into
mainfrom
fix/issue-2106-typescript-7-classic-api
Aug 7, 2026
Merged

carlos-alm merged 2 commits into
mainfrom
fix/issue-2106-typescript-7-classic-api

Conversation

@carlos-alm

Copy link
Copy Markdown
Contributor

Summary

Closes #2106

TypeScript 7.x replaced the classic in-process Program/TypeChecker API src/domain/graph/resolver/ts-resolver.ts is built entirely around (readConfigFile, createProgram, sys, forEachChild, ...) with an out-of-process client-server model under typescript/unstable/sync|async — the package's "." entry point now only exports {version, versionMajorMinor}. Redesigning ts-resolver.ts's ~70 call sites around the new proxy-object model is a substantial project of its own (as the issue itself concludes), not something to bundle into a routine dependency bump.

Changes

  • Dependabot ignore rule for major-version bumps of typescript, so it stops proposing 7.x on its weekly schedule. The dependency-bump PR that originally surfaced this (build(deps-dev): bump typescript from 6.0.3 to 7.0.2 #2093) was already closed unmerged, and package.json's own ^6.0.2 range already excludes 7.x for regular npm install/npm update — but dependabot doesn't respect that range when suggesting major bumps, so without this it would keep reopening the same PR.
  • Explicit, loud detection of the incompatibility for real-world usage: ts-resolver.ts lazy-loads typescript as a peer/optional dependency of whatever project codegraph is analyzing, not codegraph's own pin — so the dependabot rule alone doesn't protect a user running codegraph against their own TS7 project. Previously this silently and permanently no-op'd the compiler-verified type enrichment pass with only a debug()-level trace. Now detects the missing classic API (readConfigFile undefined) explicitly and logs a clear, actionable warn() pointing at this issue, instead of degrading invisibly.
  • Extracted the version-compatibility check as a small pure function (hasClassicCompilerApi) so it's unit-testable without mocking the real typescript module import.

Test plan

  • npx vitest run tests/unit/ts-resolver.test.ts — 25 passed (including 4 new tests for hasClassicCompilerApi)
  • npm test — full suite, 4588 passed
  • npx tsc --noEmit clean
  • codegraph diff-impact --staged -T reviewed — 0 unexpected callers affected
  • Manually verified the new .github/dependabot.yml ignore rule parses correctly (python3 -c "import yaml; yaml.safe_load(...)")

…ble version is detected (#2106)

TypeScript 7.x replaced the classic in-process Program/TypeChecker API
ts-resolver.ts is built entirely around (readConfigFile, createProgram,
sys, forEachChild, ...) with an out-of-process client-server model under
typescript/unstable/sync|async - the package's "." entry point now only
exports {version, versionMajorMinor}. Redesigning ts-resolver.ts's ~70
call sites around the new proxy-object model is a substantial project of
its own, not something to bundle into a routine dependency bump.

Adds a dependabot ignore rule for major-version bumps of typescript so it
doesn't keep proposing 7.x (the dependency-bump PR that surfaced this was
already closed unmerged; package.json's own ^6.0.2 range already excludes
7.x for regular installs).

Since ts-resolver.ts lazy-loads typescript as a peer/optional dependency
of whatever project codegraph is analyzing (not codegraph's own pin),
the dependabot rule alone doesn't help users on TS7 projects - previously
this silently and permanently no-op'd type enrichment for such projects
with only a debug()-level trace. Now detects the missing classic API
explicitly and logs a clear, actionable warn() instead.

docs check acknowledged

Impact: 2 functions changed, 0 affected
@greptile-apps

greptile-apps Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR prevents automated TypeScript 7 upgrades and changes TSC enrichment to resolve the compiler from each analyzed project while warning when the classic compiler API is unavailable.

  • Adds a Dependabot rule ignoring TypeScript major-version updates.
  • Adds project-relative TypeScript resolution and compatibility detection.
  • Adds unit coverage for API compatibility and module-path resolution.

Confidence Score: 4/5

The PR should not merge until TypeScript module caching is scoped per analyzed project or otherwise reset between project roots.

Sequential builds of different roots can reuse the first root's TypeScript module or cached failure, causing the later project to receive incorrect or missing compiler-based type enrichment.

Files Needing Attention: src/domain/graph/resolver/ts-resolver.ts

Important Files Changed

Filename Overview
src/domain/graph/resolver/ts-resolver.ts Adds project-relative TypeScript loading and compatibility warnings, but the unkeyed global cache causes later project roots to reuse the first root's result.
tests/unit/ts-resolver.test.ts Adds focused compatibility and resolution tests, but does not exercise sequential enrichment across different project roots.
.github/dependabot.yml Ignores TypeScript major-version updates until the resolver supports the TypeScript 7 API.

Sequence Diagram

sequenceDiagram
  participant BC as Branch comparison
  participant A as buildGraph(baseDir)
  participant Cache as Module-global _ts
  participant B as buildGraph(targetDir)
  BC->>A: Build base project
  A->>Cache: Resolve and cache base TypeScript
  BC->>B: Build target project
  B->>Cache: loadTs(targetDir)
  Cache-->>B: Return base module or null
  Note over B,Cache: targetDir is never resolved
Loading

Fix All in Claude Code

Reviews (2): Last reviewed commit: "fix(deps): resolve typescript relative t..." | Re-trigger Greptile

// TypeScript 6+ ships dual CJS/ESM exports; `.default` is the CJS interop
// namespace and is present and non-null in both TS 5.x and TS 6.x.
_ts = (await import('typescript')).default as TsModule;
const mod = (await import('typescript')).default as TsModule;

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.

P1 Project compiler bypasses compatibility check

When a standalone codegraph installation analyzes a project with TypeScript 7 installed locally, this bare import resolves from codegraph's module tree rather than the analyzed project. The import therefore enters the generic unavailable-package path, silently skipping compiler type enrichment with only a debug message instead of emitting the new actionable warning.

Knowledge Base Used: Graph Build Pipeline

Fix in Claude Code

@github-actions

github-actions Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Codegraph Impact Analysis

4 functions changed → 5 callers affected across 3 files

  • hasClassicCompilerApi in src/domain/graph/resolver/ts-resolver.ts:40 (3 transitive callers)
  • resolveTsModulePath in src/domain/graph/resolver/ts-resolver.ts:55 (3 transitive callers)
  • loadTs in src/domain/graph/resolver/ts-resolver.ts:63 (3 transitive callers)
  • enrichTypeMapWithTsc in src/domain/graph/resolver/ts-resolver.ts:138 (3 transitive callers)

…review)

A bare import('typescript') resolves via Node's module search starting
from ts-resolver.ts's own location, not the project being analyzed. A
globally installed codegraph CLI (a documented, supported install mode)
analyzing a project with its own typescript - of any version, not just
7.x - would never see it at all, silently falling back to whatever (or
no) typescript codegraph itself happens to resolve. This also made the
new v7-detection warning potentially misdiagnose which install it was
actually looking at.

Resolves typescript via require.resolve('typescript', { paths: [rootDir] })
first, falling back to resolution from codegraph's own location when the
project has no local install (preserving prior behavior for that case),
then dynamically imports the resolved absolute path instead of the bare
specifier.

docs check acknowledged

Impact: 3 functions changed, 0 affected
@carlos-alm

Copy link
Copy Markdown
Contributor Author

@greptileai

}

async function loadTs(rootDir: string): Promise<TsModule | null> {
if (_ts !== undefined) return _ts;

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.

P1 Project compiler cache crosses roots

When branch comparison builds its base and target directories sequentially, loadTs returns the compiler or null cached for the base directory without resolving TypeScript against the target directory. The target consequently uses the wrong compiler or loses compiler-based type enrichment entirely.

Fix in Claude Code

@carlos-alm
carlos-alm merged commit adf7297 into main Aug 7, 2026
30 checks passed
@carlos-alm
carlos-alm deleted the fix/issue-2106-typescript-7-classic-api branch August 7, 2026 21:05
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeScript 7.x removes the classic Program/TypeChecker API that ts-resolver.ts depends on

1 participant