Skip to content

Commit

Permalink
fix: support new vitest typings
Browse files Browse the repository at this point in the history
  • Loading branch information
AriPerkkio committed May 4, 2023
1 parent bd3a7d0 commit 46137ea
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"@types/node": "^18.16.3",
"@typescript-eslint/eslint-plugin": "^5.59.2",
"@typescript-eslint/parser": "^5.59.2",
"@vitest/expect": "^0.31.0",
"esbuild": "^0.17.18",
"eslint": "^8.39.0",
"eslint-config-prettier": "^8.8.0",
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions src/vitest/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,23 @@ import { afterEach, beforeEach, expect } from 'vitest';

import { register as __register, toBeAnnounced } from '../to-be-announced';

interface ToBeAnnouncedMatchers {
interface ToBeAnnouncedMatchers<T = any> {
/**
* Assert whether given message was announced by ARIA live region.
*
* @param politenessSetting `POLITENESS_SETTING` of the announcement
*/
toBeAnnounced(politenessSetting?: Exclude<PolitenessSetting, 'off'>): void;
toBeAnnounced(politenessSetting?: Exclude<PolitenessSetting, 'off'>): T;
}

declare module '@vitest/expect' {
interface Assertion<T> extends ToBeAnnouncedMatchers<T> {}
}

// For Vitest below 0.31.x
declare global {
namespace Vi {
interface Assertion extends ToBeAnnouncedMatchers {}
interface Assertion<T> extends ToBeAnnouncedMatchers<T> {}
}
}

Expand Down

0 comments on commit 46137ea

Please sign in to comment.