question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Click, keyboard & type TypeScript types are resolved as "any" because of wrong imports in typings

See original GitHub issue
  • @testing-library/dom version: 7.30.0
  • @testing-library/user-event version: 13.0.1
  • typescript version: 4.2.3

Problem description: The file typings/index.d.ts contains type imports from ../src/ folder, which does not exist in the distributed package, so all those types are resolved to any.

Codesandbox: https://codesandbox.io/s/romantic-shadow-uio28

image

typings/index.d.ts in the corresponding node_modules folder:

image

This concerns the following types:

  • click, clickOptions
  • keyboard, keyboardOptions, keyboardKey,
  • type, typeOptions

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:9
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
ph-fritschecommented, Mar 19, 2021

See https://github.com/testing-library/user-event/pull/596#issuecomment-802792000 .d.js won’t hurt

Rollup removed the references to lib.dom.d.ts. I’m on it.

2reactions
mkapalcommented, Mar 19, 2021

@mkapal Thanks a lot for the reports. Please check out the new version. 😃

Unfortunately, it is still not correct. Now the distributed .d.ts files contain any types, and also, there are .d.js files generated, which I’m guessing shouldn’t be there.

For example, the bundled click.d.ts file looks like this:

export function click(element: any, init: any, { skipHover, clickCount }?: {
    skipHover?: boolean | undefined;
    clickCount?: number | undefined;
}): void;
export function dblClick(element: any, init: any): void;
Read more comments on GitHub >

github_iconTop Results From Across the Web

Could not find a declaration file for module ''react-materialize ...
This error occurs when you're working on a typescript project, default modules doesn't come with types that are needed with typescript.
Read more >
Documentation - TypeScript 3.8
import type only imports declarations to be used for type annotations and declarations. It always gets fully erased, so there's no remnant of...
Read more >
TypeScript Programming with Visual Studio Code
TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. It offers classes, modules, and interfaces to help you build robust ......
Read more >
Auto import | PyCharm Documentation - JetBrains
In the Settings/Preferences dialog ( Ctrl+Alt+S ), click Editor | General | Auto Import. · In the Python section, configure automatic imports:.
Read more >
TypeScript support in Svelte - Learn web development
Early spotted bugs: The compiler checks types at compile time and provides error reporting. Readability: Static typing gives the code more ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found