fix: ship custom matcher type declarations in bundled d.ts - #9
Merged
Conversation
The custom DOM matcher declarations (toHaveText, toHaveAttribute, toExist, ...) were only pulled in via triple-slash path references in the public_api files. ng-packagr's declaration bundling follows the module graph from the entry file, so the ambient matchers-types files were dropped from the published types and consumers got TS2339 on every custom matcher. Convert the matchers-types files into proper modules (declare global namespace augmentation for jasmine/jest and a declare module augmentation for vitest) and import them from each public_api so the flattened .d.ts bundles carry them. Closes #8
Add consumer-style type tests under type-tests/ that compile against the flattened d.ts bundles in dist/spectator with tsc --noEmit. Each runner (jasmine, jest, vitest) exercises every custom DOM matcher on expect(), plus a @ts-expect-error negative control proving the assertions are meaningful. This guards against the regression from #8, where the matcher augmentations were silently dropped from the published types. Wired up as yarn test:types and run in the CI build job after the build.
dominicbachmann
force-pushed
the
fix/ship-matcher-type-declarations
branch
from
July 9, 2026 21:23
56b8fa4 to
3a80ced
Compare
dominicbachmann
marked this pull request as ready for review
July 9, 2026 21:26
5 tasks
geromegrignon
approved these changes
Jul 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The custom DOM matcher declarations (toHaveText, toHaveAttribute, toExist, ...) were only pulled in via triple-slash path references in the public_api files. ng-packagr's declaration bundling follows the module graph from the entry file, so the ambient matchers-types files were dropped from the published types and consumers got TS2339 on every custom matcher.
Convert the matchers-types files into proper modules (declare global namespace augmentation for jasmine/jest and a declare module augmentation for vitest) and import them from each public_api so the flattened .d.ts bundles carry them.
Closes #8
Description
Related issues
Fixes #8
Type of change
Breaking changes
None
Test plan
npm run buildnpm testnpm run lintChecklist
Additional context