Skip to content
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

Closed
AndreyBelym opened this issue Jun 13, 2017 · 5 comments
Closed

Type inference for customized Selectors in TypeScript #1529

AndreyBelym opened this issue Jun 13, 2017 · 5 comments
Labels
AREA: server STATE: Stale An outdated issue that will be automatically closed by the Stale bot. SYSTEM: compiler TYPE: enhancement The accepted proposal for future implementation.

Comments

@AndreyBelym
Copy link
Contributor

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

  • testcafe version: 0.16.0-alpha4
@inikulin
Copy link
Contributor

How's that?

@inikulin
Copy link
Contributor

ping @AndreyBelym

@AndreyBelym
Copy link
Contributor Author

AndreyBelym commented Jun 15, 2017

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>> {
}

@AndreyBelym AndreyBelym added TYPE: enhancement The accepted proposal for future implementation. and removed TYPE: proposal labels Feb 6, 2019
@AndreyBelym AndreyBelym removed their assignment Aug 22, 2019
@github-actions
Copy link

github-actions bot commented Dec 6, 2020

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.

@github-actions github-actions bot added the STATE: Stale An outdated issue that will be automatically closed by the Stale bot. label Dec 6, 2020
@github-actions
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AREA: server STATE: Stale An outdated issue that will be automatically closed by the Stale bot. SYSTEM: compiler TYPE: enhancement The accepted proposal for future implementation.
Projects
None yet
Development

No branches or pull requests

2 participants