I am interested in creating a library that includes a custom matcher function in TypeScript using Vitest. After following the documentation and adding a vitest.d.ts file with the necessary augmentations, everything appears to be working well. However, I have encountered an issue where other projects importing my library are not aware of the augmentation, resulting in a TypeScript error when trying to call the new matcher:
expect(data).toMatchTheTypicalExpectations()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error TS2339: Property 'toMatchTheTypicalExpectations' does not exist on type 'Assertion<Data>'.
While individuals could manually add the augmentation themselves, it would be much more efficient to export the augmentation along with the library for better accessibility.