Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

Transform to Typescript #274

Closed
subzero10 opened this issue Sep 13, 2021 · 4 comments · Fixed by #275
Closed

Transform to Typescript #274

subzero10 opened this issue Sep 13, 2021 · 4 comments · Fixed by #275
Assignees
Labels
help wanted Extra attention is needed

Comments

@subzero10
Copy link
Member

Let's transform our honeybadger-react code into typescript.
As a bonus, we won't have to manually maintain typescript definitions.

@subzero10 subzero10 added the help wanted Extra attention is needed label Sep 13, 2021
@subzero10 subzero10 self-assigned this Sep 13, 2021
@JustFly1984
Copy link

JustFly1984 commented Sep 14, 2021

I have an issue with @honeybadger-io/react and typescript in one of projects.

An error while passing a honeybadger Client type into <ErrorBoundary> component, it expects HoneyBadger

Temporary workaround I've implemented:

import ErrorBoundary from '@honeybadger-io/react';
import React from 'react';

import honeybadger from '../lib/honeybadger';

import type Honeybadger from '@honeybadger-io/js';

const App = (): JSX.Element => {
  return (
    // eslint-disable-next-line total-functions/no-unsafe-type-assertion
    <ErrorBoundary honeybadger={honeybadger as Honeybadger}>
      <>
        <Component>
      </>
    </ErrorBoundary>
  );
};

Full error text:

No overload matches this call.
  Overload 1 of 2, '(props: Props | Readonly<Props>): ErrorBoundary', gave the following error.
    Type 'Client' is not assignable to type 'Honeybadger'.
      Type 'Client' is missing the following properties from type 'Honeybadger': errorHandler, requestHandler, lambdaHandler
  Overload 2 of 2, '(props: Props, context: any): ErrorBoundary', gave the following error.
    Type 'Client' is not assignable to type 'Honeybadger'.
      Type 'Client' is not assignable to type 'Honeybadger'.ts(2769)

@subzero10
Copy link
Member Author

Hey @JustFly1984 , can you please try installing branch and let us know if you still experience the issue?

npm command to install a specific branch:

npm install@honeybadger-io/react#fix-ts-definitions --save

Thanks!

@joshuap
Copy link
Member

joshuap commented Sep 14, 2021

@JustFly1984 this should now be fixed in @honeybadger-io/[email protected]

@JustFly1984
Copy link

Yes, it is fixed!Thank you @joshuap

@subzero10 subzero10 linked a pull request Sep 20, 2021 that will close this issue
9 tasks
@subzero10 subzero10 reopened this Sep 20, 2021
subzero10 added a commit that referenced this issue Sep 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants