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

BlobProvider type error TS2769 #2169

Closed
sgarnotel opened this issue Jan 30, 2023 · 3 comments · Fixed by #2172
Closed

BlobProvider type error TS2769 #2169

sgarnotel opened this issue Jan 30, 2023 · 3 comments · Fixed by #2172

Comments

@sgarnotel
Copy link

Describe the bug
The usage example of BlobProvider throw a typescript error

<BlobProvider document={MyDoc}>
  {({ blob, url, loading, error }) => {
    // Do whatever you need with blob here
    return <div>There's something going on on the fly</div>;
  }}
</BlobProvider>

To Reproduce
Steps to reproduce the behavior including code snippet (if applies):

  1. Use the example code in a typescript project
  2. See error TS2769

Expected behavior
No typescript error

Screenshots
Sorry, this is in French

Aucune surcharge ne correspond à cet appel.
  La surcharge 1 sur 2, '(props: PropsWithChildren<BlobProviderProps> | Readonly<PropsWithChildren<BlobProviderProps>>): BlobProvider', a généré l'erreur suivante.
    Impossible d'assigner le type '({ blob, url, loading, error }: BlobProviderParams) => Element' au type '((params: BlobProviderParams) => ReactNode) & ReactNode'.
      Impossible d'assigner le type '({ blob, url, loading, error }: BlobProviderParams) => Element' au type '((params: BlobProviderParams) => ReactNode) & string'.
        Impossible d'assigner le type '({ blob, url, loading, error }: BlobProviderParams) => Element' au type 'string'.
  La surcharge 2 sur 2, '(props: PropsWithChildren<BlobProviderProps>, context: any): BlobProvider', a généré l'erreur suivante.
    Impossible d'assigner le type '({ blob, url, loading, error }: BlobProviderParams) => Element' au type '((params: BlobProviderParams) => ReactNode) & ReactNode'.ts(2769)
index.d.ts(419, 5): Le type attendu provient de la propriété 'children', qui est déclarée ici sur le type 'IntrinsicAttributes & IntrinsicClassAttributes<BlobProvider> & Readonly<PropsWithChildren<BlobProviderProps>>'
index.d.ts(419, 5): Le type attendu provient de la propriété 'children', qui est déclarée ici sur le type 'IntrinsicAttributes & IntrinsicClassAttributes<BlobProvider> & Readonly<PropsWithChildren<BlobProviderProps>>'

Desktop (please complete the following information):

  • OS: Linux Ubuntu 22.04
  • Browser any
  • React-pdf version 3.1.1
@francofantini
Copy link

Same error over here. English version:

 Type error: No overload matches this call.
   Overload 1 of 2, '(props: PropsWithChildren<BlobProviderProps> | Readonly<PropsWithChildren<BlobProviderProps>>): BlobProvider', gave the following error.
     Type '({ url }: BlobProviderParams) => Element' is not assignable to type '((params: BlobProviderParams) => ReactNode) & ReactNode'.
       Type '({ url }: BlobProviderParams) => Element' is not assignable to type '((params: BlobProviderParams) => ReactNode) & string'.
         Type '({ url }: BlobProviderParams) => Element' is not assignable to type 'string'.
   Overload 2 of 2, '(props: PropsWithChildren<BlobProviderProps>, context: any): BlobProvider', gave the following error.
     Type '({ url }: BlobProviderParams) => Element' is not assignable to type '((params: BlobProviderParams) => ReactNode) & ReactNode'.

@dmarkow
Copy link

dmarkow commented Jan 30, 2023

https://github.com/diegomura/react-pdf/blob/master/packages/renderer/index.d.ts#L428

The PropsWithChildren type wrapper's children props is conflicting with the children prop defined on BlobProviderProps. Changing this line to remove PropsWithChildren seems to work:

class BlobProvider extends React.Component<BlobProviderProps> {}

@rdennis
Copy link
Contributor

rdennis commented Jan 31, 2023

I have a pull request in for this issue (#2172) and would love any input on it.

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

Successfully merging a pull request may close this issue.

5 participants