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

Missing title TypeScript type #221

Open
grempe opened this issue Nov 12, 2022 · 3 comments
Open

Missing title TypeScript type #221

grempe opened this issue Nov 12, 2022 · 3 comments

Comments

@grempe
Copy link

grempe commented Nov 12, 2022

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

@rosskhanas
Copy link
Owner

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

@mercpls
Copy link
Contributor

mercpls commented Dec 9, 2022

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

@relativityboy
Copy link

relativityboy commented Oct 26, 2023

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.

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

4 participants