Skip to content

fix: ship custom matcher type declarations in bundled d.ts - #9

Merged
dominicbachmann merged 2 commits into
mainfrom
fix/ship-matcher-type-declarations
Jul 10, 2026
Merged

fix: ship custom matcher type declarations in bundled d.ts#9
dominicbachmann merged 2 commits into
mainfrom
fix/ship-matcher-type-declarations

Conversation

@dominicbachmann

Copy link
Copy Markdown
Member

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

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that changes the public API)
  • Documentation only
  • Refactor, test, or chore (no user-facing change)

Breaking changes

None

Test plan

  • npm run build
  • npm test
  • npm run lint
  • Verified in the demo app (if applicable)

Checklist

  • Issue discussed or bug clearly described (link issue when applicable)
  • Tests added or updated for behavioral changes
  • Documentation updated (README, JSDoc, migration notes as needed)
  • [] Public API changes documented; breaking changes called out
  • CHANGELOG updated (if the repository maintains one and the change is user-facing)
  • Commit messages follow Conventional Commits
  • I agree to follow the OpenNG Foundation Code of Conduct

Additional context

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
dominicbachmann force-pushed the fix/ship-matcher-type-declarations branch from 56b8fa4 to 3a80ced Compare July 9, 2026 21:23
@dominicbachmann
dominicbachmann marked this pull request as ready for review July 9, 2026 21:26
@dominicbachmann
dominicbachmann merged commit fc58d13 into main Jul 10, 2026
4 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.

[Bug]: Custom DOM matchers not re-exported or wired into expect()

2 participants