fix: explicitly mention Matcher type in BoundFunction TS type#335
fix: explicitly mention Matcher type in BoundFunction TS type#335hmttrp wants to merge 1 commit into
Matcher type in BoundFunction TS type#335Conversation
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.
kentcdodds
left a comment
There was a problem hiding this comment.
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
: neverBut 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
BoundFunctionto not infer the type of thetextproperty anymore but explicitly reference the typeMatcherinstead.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
textproperty should be of typeSelectorMatcherOptions | undefinedand theoptionstype is unknown which is both wrong.It should be
I think this is a regression from #139
How:
Removing type inference and use
Matchertype 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 dtslintbut 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.