Open
Description
@testing-library/jest-dom
version: 6.4.5node
version: 20.12.0jest
(orvitest
) version: 29.7.0npm
(oryarn
) version: 10.5.0
Relevant code or config:
What you did:
Tried to start up a storybook using a default angular project generated via ng new
and ng generate library
What happened:
ERROR in node_modules/@testing-library/jest-dom/types/matchers-standalone.d.ts:9:3 - error TS2300: Duplicate identifier 'toHaveClass'.
9 toHaveClass: (expected: any, ...rest: string[]) => MatcherReturnType
~~~~~~~~~~~
ERROR in node_modules/@testing-library/jest-dom/types/matchers-standalone.d.ts:10:3 - error TS2300: Duplicate identifier 'toHaveClass'.
10 toHaveClass: (
~~~~~~~~~~~
ERROR in node_modules/@testing-library/jest-dom/types/matchers-standalone.d.ts:10:3 - error TS2717: Subsequent property declarations must have the same type. Property 'toHaveClass' must be of type '(expected: any, ...rest: string[]) => MatcherReturnType', but here has type '(expected: any, className: string, options?: { exact: boolean; } | undefined) => MatcherReturnType'.
10 toHaveClass: (
~~~~~~~~~~~
node_modules/@testing-library/jest-dom/types/matchers-standalone.d.ts:9:3
9 toHaveClass: (expected: any, ...rest: string[]) => MatcherReturnType
~~~~~~~~~~~
'toHaveClass' was also declared here.
Reproduction:
Problem description:
matchers-standalone.d.ts seems to have an invalid syntax. See microsoft/TypeScript#4462 for a longer explanation.
Suggested solution:
interface OverloadedMatchers {
toHaveClass(expected: any, ...rest: string[]) : MatcherReturnType
toHaveClass(
expected: any,
className: string,
options?: {exact: boolean},
) : MatcherReturnType
}
seems to work, and is probably what the original code intended (overloaded method signature). Note the change from arrow function to class method syntax.
Metadata
Metadata
Assignees
Labels
No labels