Skip to content

[finding] @objectstack/plugin-auth's typecheck cannot pass unless the package's OWN dist/ is built, and no task dependency says so #11620

Description

@os-sam

Found while verifying #11579 (PR #11619) in a fresh worktree. Filed unassigned, not fixed there — out of that card's scope.

What happens

On a tree where @objectstack/plugin-auth's dependency closure is built but the package itself is not, pnpm --filter @objectstack/plugin-auth typecheck fails:

examples/basic-usage.ts(13,28): error TS2307: Cannot find module '@objectstack/plugin-auth' or its corresponding type declarations.
ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL @objectstack/plugin-auth@17.2.0 typecheck: `tsc --noEmit && tsc --noEmit -p tsconfig.examples.json`
Exit status 2

The first tsc --noEmit (the package's own sources) passes — the && chain reaches the second command. The failure is entirely the examples program.

Why

packages/plugins/plugin-auth/package.json:

"typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.examples.json"

examples/basic-usage.ts imports the package by its own package name, which resolves through exports to ./dist/index.d.ts. So this program's inputs include an artifact the package itself produces.

Nothing declares that. turbo.json:

"typecheck": { "dependsOn": ["^build"], "inputs": ["$TURBO_DEFAULT$", "!dist/**", ...] }

^build is dependencies' build, never the package's own — and inputs explicitly excludes dist/**, so turbo does not even consider it. turbo run typecheck --filter=@objectstack/plugin-auth on such a tree fails the same way.

Scope: exactly one package today

tsconfig.examples.json exists in one package repo-wide (find packages -name tsconfig.examples.jsonpackages/plugins/plugin-auth/tsconfig.examples.json), and it is the only typecheck script with a second -p program. So this is one package's shape, not a class — which is part of why it stays quiet.

Why it is finding and not a bug

CI does not hit it: the lint job builds the workspace before type-checking, so dist/ is always present there. The cost is local, and it is a misleading cost rather than a slow one — TS2307: Cannot find module '@objectstack/plugin-auth' reads as a broken import or a bad workspace link, not as "build this package first". It cost one round on #11579 before the && chain made the real cause legible.

Possible repairs (not chosen here)

  • give the examples program its own task with dependsOn: ["build"] (self), leaving typecheck alone;
  • point the examples program at src/ via a path mapping in tsconfig.examples.json, so it stops depending on an artifact;
  • leave it and say so in the script name (e.g. typecheck:examples), so the ordering requirement is visible at the call site.

Which one is right depends on whether the examples are meant to type-check against the published surface (today's behaviour, and arguably the point of an examples program) or against the sources. That is the decision this card is recording, not making.


Generated by Claude Code

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions