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

Add Typescript Support #25

Open
piyushchauhan opened this issue Feb 27, 2022 · 10 comments
Open

Add Typescript Support #25

piyushchauhan opened this issue Feb 27, 2022 · 10 comments

Comments

@piyushchauhan
Copy link

TS7016: Could not find a declaration file for module 'use-react-screenshot'. '/project/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/use-react-screenshot/dist/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/use-react-screenshot` if it exists or add a new declaration (.d.ts) file containing `declare module 'use-react-screenshot';`
    16 |   ReactFlowProvider,
    17 | } from 'react-flow-renderer';
  > 18 | import { useScreenshot } from 'use-react-screenshot';
       |                               ^^^^^^^^^^^^^^^^^^^^^^
@piyushchauhan piyushchauhan changed the title Added Typescript Support Add Typescript Support Feb 27, 2022
@shubham-vunet
Copy link

Any updates!!

@JVisi
Copy link

JVisi commented Nov 7, 2022

Can I help with it?
I really like the idea and the module, I'd gladly help adding TS support

@osro
Copy link

osro commented Nov 24, 2022

+1

@AshishKapoor
Copy link

Quick Fix: Add this to your react-app-env.d.ts file

declare module 'use-react-screenshot' {
  declare
  useScreenshot
  export { useScreenshot }
}

@electroheadfx
Copy link

@AshishKapoor where you put this file ? I tried from root app (Next) it doesn't work. Thx

@AshishKapoor
Copy link

AshishKapoor commented Dec 3, 2022

@AshishKapoor where you put this file ? I tried from root app (Next) it doesn't work. Thx

Try adding it to your next-env.d.ts file at root. +cc @electroheadfx

@trandinhhiep789
Copy link

Quick Fix: Add this to your react-app-env.d.ts file

declare module 'use-react-screenshot' {
  declare
  useScreenshot
  export { useScreenshot }
}

Yes, It worked for me

@martsie
Copy link

martsie commented Jul 24, 2023

A more detailed type definition to use with return types and hook options.

declare module 'use-react-screenshot' {
  type UseScreenshot = (options: {
    type: 'image/jpeg' | 'image/png'
    quality: number
  }) => [string | null, (ref: HTMLDivElement) => void]
  declare const useScreenshot: UseScreenshot
  export { useScreenshot }
}

@capsuleman
Copy link

Hello!

I'm eager to address this issue. I recently started using this great library, and the lack of a type description is a significant problem for projects utilizing Typescript. Here are two options to tackle this issue:

  1. Define a static TypeScript interface in the library: this is a quick solution that doesn't involve updating existing files. However, it's incomplete and wouldn't evolve with library updates.

  2. Migrate all JavaScript files to TypeScript: It's a bit more involved but ensures consistency even in the future.

@vre2h, I'd like to pursue the second option. Is that acceptable to you? Are there any potential blockers you can think of?

Best regards,
Guillaume

@ojonah
Copy link

ojonah commented Jun 20, 2024

Yes please adding Typescript declarations would be helpful. 🙏🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants