Skip to content

Commit

Permalink
fix: correct types for "./matchers" export
Browse files Browse the repository at this point in the history
  • Loading branch information
jakeboone02 committed Jan 4, 2024
1 parent b64b953 commit c03f806
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
},
"./matchers": {
"require": {
"types": "./types/matchers.d.ts",
"types": "./types/matchers-standalone.d.ts",
"default": "./dist/matchers.js"
},
"import": {
"types": "./types/matchers.d.ts",
"types": "./types/matchers-standalone.d.ts",
"default": "./dist/matchers.mjs"
}
},
Expand Down
30 changes: 30 additions & 0 deletions types/matchers-standalone.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import {type TestingLibraryMatchers} from './matchers'

type TLM = TestingLibraryMatchers<any, void>

interface MatcherReturnType {
pass: boolean
message: () => string
}

interface OverloadedMatchers {
toHaveClass: (expected: any, ...rest: string[]) => MatcherReturnType
toHaveClass: (
expected: any,
className: string,
options?: {exact: boolean},
) => MatcherReturnType
}

declare namespace matchersStandalone {
type MatchersStandalone = {
[T in keyof TLM]: (
expected: any,
...rest: Parameters<TLM[T]>
) => MatcherReturnType
} & OverloadedMatchers
}

declare const matchersStandalone: matchersStandalone.MatchersStandalone &
Record<string, any>
export = matchersStandalone

0 comments on commit c03f806

Please sign in to comment.