helen-dikareva / axe-testcafe

The helper for using Axe in TestCafe tests
36 stars 13 forks source link

Move React type definitions to DefinitelyTyped #8

Closed JoshuaKGoldberg closed 5 years ago

JoshuaKGoldberg commented 5 years ago

It's great that you support TypeScript types! But: in a project that uses two testing libraries with global test variables declared, the declare var test: TestFn; in testcafe/ts-defs/index.d.ts will conflict with the other test library's types.

For example, in a project with both Jest and TestCafe:

package.json:

{
    "dependencies": {
        "@types/jest": "23.3.13",
        "axe-testcafe": "1.1.0",
        "jest": "24.3.0",
        "testcafe": "0.23.3"
    }
}

tsconfig.json:

{
    "compilerOptions": {
        "moduleResolution": "node"
    },
    "include": ["./src/**/*.ts"]
}

You get this lovely error in node_modules/@types/jest/index.d.ts[33:13]:

Subsequent variable declarations must have the same type.  Variable 'test' must be of type 'TestFn', but here has type 'It'.
ts(2403)

One clean solution would be to separate out the TypeScript definitions from this library into an auto-published @types/axe-testcafe on DefinitelyTyped. They'd then be installable as a separate opt-in package and benefit from the heavily automated maintenance there.

jrparish commented 5 years ago

I believe this is not an issue in the latest version. I think it's nice having the typings with the project so there is only one dependency version to maintain.

JoshuaKGoldberg commented 5 years ago

@jrparish this happens with testcafe@1.3.3.

jrparish commented 5 years ago

Maybe its the testcafe typings that you're having the issue with. This project's typings don't have the test declaration - https://github.com/helen-dikareva/axe-testcafe/blob/master/index.d.ts

JoshuaKGoldberg commented 5 years ago

I think you're right, yeah - now it's just them. Thanks! 🙌