react-qr-code icon indicating copy to clipboard operation
react-qr-code copied to clipboard

Missing `title` TypeScript type

Open grempe opened this issue 3 years ago • 4 comments

In the README, where the API is described, it indicates that a title property (string) will be accepted.

However, trying to specify that in a Next.js TypeScript project shows an error:

No overload matches this call.
  Overload 1 of 2, '(props: QRCodeProps | Readonly<QRCodeProps>): QRCode', gave the following error.
    Type '{ id: string; fgColor: string; size: number; level: string; title: string; value: string; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<QRCode> & Readonly<QRCodeProps>'.
      Property 'title' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<QRCode> & Readonly<QRCodeProps>'.
  Overload 2 of 2, '(props: QRCodeProps, context: any): QRCode', gave the following error.
    Type '{ id: string; fgColor: string; size: number; level: string; title: string; value: string; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<QRCode> & Readonly<QRCodeProps>'.
      Property 'title' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<QRCode> & Readonly<QRCodeProps>'.ts(2769)

The interface defined here doesn't specify title.

https://github.com/rosskhanas/react-qr-code/blob/master/types/index.d.ts

grempe avatar Nov 12 '22 19:11 grempe

@grempe I personally do not use TypeScript, would appreciate a PR 🙂

rosskhanas avatar Nov 13 '22 12:11 rosskhanas

Actually, this shows an issue

https://github.com/rosskhanas/react-qr-code/blob/master/src/components/QRCodeSurface/index.native.js The native component doesn't have a title prop being used.

While the web component, https://github.com/rosskhanas/react-qr-code/blob/master/src/components/QRCodeSurface/index.js does have

being used. All it's doing is wrapping a title with <code><title></code> and should probably be removed, as users can pass <code>{children}</code> to both components and have the same expected result.

mercpls avatar Dec 09 '22 06:12 mercpls

Repo appears to be a bit broken where title is concerned. import QRCode from 'react-qr-code' does not give a component that accepts title

Also, example should be a totally separate. (Importing QRCode from ../lib is unlikely to yield a functional codebase except on your local)

It might be that this repo needs tests to avoid further regression.

relativityboy avatar Oct 26 '23 02:10 relativityboy