Skip to content

Set rootDir so library imports resolve in tsc - #71

Merged
raphvallee merged 1 commit into
mainfrom
fix/frontend-library-import-rootdir
Oct 2, 2026
Merged

raphvallee merged 1 commit into
mainfrom
fix/frontend-library-import-rootdir

Conversation

@raphvallee

Copy link
Copy Markdown
Owner

Problem

tsc rejects every one of the eleven library/src/models import sites in the frontend:

src/app/api.service.ts(4,46): error TS6059: File
'.../library/src/models.ts' is not under 'rootDir' '.../frontend'.
'rootDir' is expected to contain all source files.

The components and api.service.ts import the shared interfaces straight from the library source (../../../library/src/models) rather than from a built package, so the program's inputs reach outside frontend/. With no rootDir configured, tsc infers frontend/ and rejects them.

TypeScript 5.9 tolerated this. bd4cb9a ("Upgrade to Angular 22") bumped the frontend from typescript: ^5.9.3 to ^6.0.3, which enforces rootDir. That is the regression.

Why CI stayed green

bun run build runs ng build, whose @angular/build esbuild pipeline does not enforce rootDir. Only a direct tsc invocation breaks, which is why this surfaced in the editor rather than in a failing build. The Frontend CI workflow never caught it.

Fix

One line in frontend/tsconfig.app.json:

"rootDir": ".."

The repo root contains both frontend/src and library/src, so the program's inputs are all covered.

Verification

Check Before After
npx tsc -p tsconfig.app.json --noEmit (TS 6.0.3) TS6059 on 11 sites exit 0, clean
npx ng build pass pass

TS 5.9.3 was also run against the pre-fix config to confirm it was clean there, isolating the TypeScript bump as the trigger.

Not included

This fixes the type-check only. Two unrelated local issues surfaced during diagnosis and are left alone:

  • A stale mock-api.cjs from a prior session was sharing port 3000 with the real backend, splitting requests between the two. Its /brand/:id lookup used a raw string id, so every brand detail request returned 404 {"error":"not found"}. Killed locally; nothing in the repo.
  • bun on PATH resolves to a 1.3.14 install while backend/src/bun-version-guard.ts requires >= 1.4.1. A fresh bun invocation can fail to start the backend. Needs bun upgrade; an environment fix, not a repo one.

The components and api.service.ts import the shared interfaces straight
from library/src/models instead of a built package, so the program's
inputs reach outside frontend/. tsc inferred rootDir as frontend/ and
rejected all eleven import sites with TS6059.

TypeScript 5.9 tolerated this, but bd4cb9a bumped the frontend to ^6.0.3,
which enforces rootDir. ng build stayed green the whole time because
@angular/build's esbuild pipeline does not check it, so only tsc broke.

Point rootDir at the repo root, which contains both frontend/src and
library/src.
@raphvallee
raphvallee merged commit e44c098 into main Oct 2, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant