Avoid using Function
type in custom Matchers where a callback is allowed #382
Closed
Description
I'm submitting a...
[ ] Regression (a behavior that used to work and stopped working in a new release)
[X] Bug report
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:
Current behavior
The toHaveText
/ toHaveExactText
matchers allow passing of a callback. Typings look like
toHaveText(text: string | string[] | Function, exact?: boolean): boolean;
toContainText(text: string | string[] | Function, exact?: boolean): boolean;
toHaveExactText(text: string | string[] | Function): boolean;
The docs show how to use the callback form as
expect('.zippy__content').toHaveText(text => text.includes('..'));
This results in a TS7006 error, Parameter 'text' implicitly has an 'any' type
-- I think only when compiled with the noImplicitAny
flag.
Expected behavior
The typings should specify the correct signature for the calback instead of Function
. That's probably (value: string) => boolean
, if I understand the way it's meant to work.
What is the motivation / use case for changing the behavior?
Callers should be able to declare a callback without explicit typing.
Environment
Angular version: 11.0.4
Metadata
Assignees
Labels
No labels