-
Notifications
You must be signed in to change notification settings - Fork 467
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: explicitly mention Matcher
type in BoundFunction
TS type
#335
Conversation
Type inference was not working properly in some cases. Since all queries have the `Matcher` type for the text property the types can be explicit here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems fine to me, but I don't do much with the TypeScript so I'd like another reviewer please. Thanks!
|
I just recognised, that some queries also do have a |
There's not a way to check AFAIK. Maybe We definitely want the typings to be as accurate as possible. |
One way I thought that would additionally support the export type BoundFunction<T> =
T extends (attribute: string, element: HTMLElement, ...rest: infer P) => infer R
? (...rest: P) => R
: T extends (element: HTMLElement, ...rest: infer P) => infer R
? (...rest: P) => R
: never But it does not seem to work. |
I honestly have no idea. Unfortunately we don't really have any consistent maintainers of the TypeScript definitions and to be frank I'm getting tired of drive-by contributors making changes to the definitions which I can't really verify 😬 If you're willing to commit to being a dedicated TypeScript maintainer then that's great. Otherwise I'm starting to think we should just remove the TypeScript definitions and have people put it in DefinitelyTyped instead ☹ |
Fair point. I am just starting to use typescript in production application and therefore don't think that it would be reasonable to maintain the types for a bigger project. Will close this in favor of #337 |
What:
Changing typescript type definitions for
BoundFunction
to not infer the type of thetext
property anymore but explicitly reference the typeMatcher
instead.Why:
Using testcafe-testing-library along with typescripts creates a typing error.
This seems to be due to wrongly inferred types.
In the image above you can see, that the
text
property should be of typeSelectorMatcherOptions | undefined
and theoptions
type is unknown which is both wrong.It should be
I think this is a regression from #139
How:
Removing type inference and use
Matcher
type explicitly. I did not find a case where text is not of typeMatcher
.Checklist:
docs site
Additional Comment
I tried to validate the types by using
npm run dtslint
but it fails for typescript 2.8. Also the master branch is failing for me. Can someone validate if this is true or if it is an issue on my machine.