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.

Missing typescript declaration file for module

See original GitHub issue

Could not find a declaration file for module ‘react-in-viewport’. ‘/Users/Projects/xyz/node_modules/react-in-viewport/dist/index.js’ implicitly has an ‘any’ type.

Try npm install @types/react-in-viewport if it exists or add a new declaration (.d.ts) file containing declare module 'react-in-viewport';ts(7016)

I’m using typescript for my project and tsconfig.json got strict mode true.

Would you like me to make one in DefinitelyTyped? Or is it already done?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
GuiMercier1commented, Feb 26, 2020

Hello, “a minima” I’ve solved it by creating the following “react-in-viewport.d.ts” file in src/@types :

declare module 'react-in-viewport' {
    function handleViewport(block: ReactNode, options?: any, config?: any): any
    export = handleViewport
}

Obviously it must be improved later to describe props, options and config, but at least your lint won’t block you.

2reactions
timur-mutcommented, Mar 18, 2021
declare module 'react-in-viewport' {
  import {ReactNode, MutableRefObject} from "react";
  export declare function useInViewport(ref: MutableRefObject<any>, options?: any, config?: any, props: any): {
    inViewport: boolean,
    enterCount: number,
    leaveCount: number,
  }

  function handleViewport(block: ReactNode, options?: any, config?: any): any
  export = handleViewport
}

Read more comments on GitHub >

github_iconTop Results From Across the Web

Could not find a declaration file for module 'module-name ...
In order for this to work, I had to make declare module '...' the first line of code in the module.d.ts file, and...
Read more >
How to Declare Missing Types for External Libraries -- newline
In this case type to find them in DefinitelyTyped repository and install them. If DefinitelyTyped doesn't have type declarations for a library ...
Read more >
v4.0.0 missing TypeScript declaration files #3846 - GitHub
Version 4.0.0 is missing the declaration files to make use of TypeScript typing. This is affecting all packages part of v4.0.0: @tanstack ...
Read more >
[TypeScript] Error: Could not find a declaration file for module ...
Solution: All you have to do is edit your TypeScript Config file (tsconfig. json) and add a new key value pair as. I...
Read more >
Fixing the TS7016 Error | Atomist Blog
Make a file somewhere among your TypeScript source. Call it types.d.ts (or whatever; see above) and put in it: declare module ...
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