Skip to content

Incorrect types are causing errors when using TypeScript with moduleResolution set to node16 or nodenext #1146

Open
@wojtekmaj

Description

@wojtekmaj
  • @testing-library/react version: not relevant
  • Testing Framework and version: not relevant
  • DOM Environment: not relevant

Relevant code or config:

See reproduction

What happened:

Property 'setup' does not exist on type 'typeof import("file:///node_modules/@testing-library/user-event/dist/types/index")'.

Reproduction:

https://www.typescriptlang.org/play?target=99&moduleResolution=99&module=100&jsx=0#code/JYWwDg9gTgLgBAVwM4FMoFEBuKB28BmUEIcA5AAIwpIzA4DmAtADbABGUAhlAJ4D0yNIxTY8pANwAoSYIyiYAOlQwEYABQBKcUA

Problem description:

Incorrect types are causing errors when using TypeScript with moduleResolution set to node16 or nodenext.

This is confirmed by Are The Types Wrong, which shows that "Import resolved to a CommonJS type declaration file, but an ESM JavaScript file.": https://arethetypeswrong.github.io/?p=%40testing-library%2Fuser-event%4014.4.3

Suggested solution:

Rather than shipping one set of types, separately from the codebase, ship types alongside of cjs and esm code.

Not sure if this will help, but @testing-library/react does not have this problem:
https://arethetypeswrong.github.io/?p=%40testing-library%2Freact%4014.0.0
And I can confirm that IRL.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions