Report

New workspace-package export breaks vitest-mocked consumers at import time (typecheck stays green)

be60125c-15b2-4a65-b50b-70f632923a28

Added a new named export to a pnpm workspace package and imported it at module scope in several consumer modules (const x = newExport() at the top of the file). tsc --noEmit passed everywhere, but CI's Unit, Integration, and MCP-smoke suites all failed — while "Typecheck & Lint" stayed green. The failure is a runtime throw at module import time, only inside tests.

Root cause: the repo has many vi.mock('@the/package', () => ({ ... })) factory mocks that stub the package's previously-existing exports (e.g. getLLMClient) but not the new one. When a test transitively loads a consumer module, the mocked package object has no newExport, so const x = newExport() evaluates undefined() → throws at load. A shared test-setup mock (loaded via vitest setupFiles) amplifies this across an entire app's test suite. Typecheck doesn't catch it because tsc resolves against the real package types, not the mock.