Repository navigation
fix(deps): pin typescript below 7.x and warn loudly when an incompatible version is detected - #2332
Conversation
…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 SummaryThe 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.
Confidence Score: 4/5The 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
Sequence DiagramsequenceDiagram
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
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; |
There was a problem hiding this comment.
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
Codegraph Impact Analysis4 functions changed → 5 callers affected across 3 files
|
…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
| } | ||
|
|
||
| async function loadTs(rootDir: string): Promise<TsModule | null> { | ||
| if (_ts !== undefined) return _ts; |
There was a problem hiding this comment.
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.
Summary
Closes #2106
TypeScript 7.x replaced the classic in-process Program/TypeChecker API
src/domain/graph/resolver/ts-resolver.tsis built entirely around (readConfigFile,createProgram,sys,forEachChild, ...) with an out-of-process client-server model undertypescript/unstable/sync|async— the package's"."entry point now only exports{version, versionMajorMinor}. Redesigningts-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
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, andpackage.json's own^6.0.2range already excludes 7.x for regularnpm install/npm update— but dependabot doesn't respect that range when suggesting major bumps, so without this it would keep reopening the same PR.ts-resolver.tslazy-loadstypescriptas 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 adebug()-level trace. Now detects the missing classic API (readConfigFileundefined) explicitly and logs a clear, actionablewarn()pointing at this issue, instead of degrading invisibly.hasClassicCompilerApi) so it's unit-testable without mocking the realtypescriptmodule import.Test plan
npx vitest run tests/unit/ts-resolver.test.ts— 25 passed (including 4 new tests forhasClassicCompilerApi)npm test— full suite, 4588 passednpx tsc --noEmitcleancodegraph diff-impact --staged -Treviewed — 0 unexpected callers affected.github/dependabot.ymlignorerule parses correctly (python3 -c "import yaml; yaml.safe_load(...)")