-
Notifications
You must be signed in to change notification settings - Fork 674
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
Type inference for customized Selectors in TypeScript #1529
Comments
How's that? |
ping @AndreyBelym |
Ok, surprisingly Flow was better at generics, TypeScript has some issues:
Without typechecking for arguments and return type it looks like: interface CustomPropertiesMap {
{[prop: string]: (node: Element) => any})
}
interface CustomPropertiesOnSnapshot<T> {
[P in keyof T]: any
}
interface CustomPropertiesOnSelector<T> {
[P in keyof T]: Promise<any>
}
interface TestController {
//...
addCustomDOMProperties<T extends CustomPropertiesMap>(props: T): CustomSelector<T>;
//...
}
interface CustomSelector<T> extends Selector, CustomPropertiesOnSelector<T> {
(...args: any[]): CustomSelectorPromise<T>;
}
interface CustomSelectorPromise<T> extends SelectorPromise, CustomPropertiesOnSelector<T>, Promise<NodeSnapshot & CustomPropertiesOnSnapshot<T>> {
} |
This issue has been automatically marked as stale because it has not had any activity for a long period. It will be closed and archived if no further activity occurs. However, we may return to this issue in the future. If it still affects you or you have any additional information regarding it, please leave a comment and we will keep it open. |
We're closing this issue after a prolonged period of inactivity. If it still affects you, please create a new issue with up-to-date information. Thank you. |
Are you requesting a feature or reporting a bug?
Feature
What is the current behavior?
Currently you have to specify interfaces of customized Selector and customized Snapshot: https://github.com/DevExpress/testcafe/blob/master/test/server/data/test-suites/typescript-defs/selectors.ts#L760
What is the expected behavior?
These interfaces can be inferred automatically by Mapped Types from TypeScript 2.1: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-1.html#mapped-types
Specify your
The text was updated successfully, but these errors were encountered: