rollbar-react
rollbar-react copied to clipboard
TypeScript types don't match implementation
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 afallbackUIprop, which is aReactNode(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 beReact.ComponentType<{}>orReact.FC<{}>.historyContexthas multiple issues:- The documentation (and implementation) claims to support both History v4 and History v5, but the types are only compatible with V4.
filterandformatterfunctions receivelocationas a string, but it is in fact aLocationobject, not a string.filterandformatterare 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
actionandfilter, but this seems like a copy-paste mistake and the correct signature is probably(location: Location, action: string). - You need to define your own
Locationtype, unless you want to take a dependency onhistory.
- The function returns a callback which receives an object consisting of
+1 for the fallbackUI problem. What would be a good workaround to fix that for now?
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
Any updates about this issue? tnx
+1 I'm itching for a fix. For context, this issue occurs with React 18 and not React 17