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

TypeScript types don't match implementation #69

Open
paavohuhtala opened this issue Aug 25, 2022 · 4 comments
Open

TypeScript types don't match implementation #69

paavohuhtala opened this issue Aug 25, 2022 · 4 comments

Comments

@paavohuhtala
Copy link

paavohuhtala commented Aug 25, 2022

Currently, the TypeScript type definitions do not match the documentation nor the implementation. Here are the problems I've encountered so far in one afternoon of integrating the library:

  • <ErrorBoundary> has a fallbackUI prop, which is a ReactNode (the result of rendering a component) in types, but is assumed to be a function (a functional component) in the implementation. The correct type would most likely be React.ComponentType<{}> or React.FC<{}>.
  • historyContext has multiple issues:
    • The documentation (and implementation) claims to support both History v4 and History v5, but the types are only compatible with V4.
    • filter and formatter functions receive location as a string, but it is in fact a Location object, not a string.
    • filter and formatter are documented as optional, but they are required arguments in types.
    • Furthermore, the types are not correct even for V4:
      • The function returns a callback which receives an object consisting of action and filter, but this seems like a copy-paste mistake and the correct signature is probably (location: Location, action: string).
      • You need to define your own Location type, unless you want to take a dependency on history.
@gtupak
Copy link

gtupak commented Oct 19, 2022

+1 for the fallbackUI problem. What would be a good workaround to fix that for now?

@dwightgunning
Copy link

As a workaround, I followed this guide to overriding the type definitions (in reality inserting new type definitions that have higher precedence).

Versions:

  • @rollbar/react: ^0.11.1
  • @types/node: ^16.8.4
  • @types/react: ^18.0.25
  • rollbar: ^2.25.2
  • react: ^18.2.0
  • node: ^16.17.0
  • typescript: ^4.8.3

@ziperfal123
Copy link

Any updates about this issue? tnx

@walkingbrad
Copy link

+1 I'm itching for a fix. For context, this issue occurs with React 18 and not React 17

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

5 participants