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

Transform to Typescript - #274 #275

Merged
merged 19 commits into from
Sep 21, 2021
Merged

Transform to Typescript - #274 #275

merged 19 commits into from
Sep 21, 2021

Conversation

subzero10
Copy link
Member

@subzero10 subzero10 commented Sep 18, 2021

Status

READY

Description

This PR introduces a typescript version of the react component, which means auto-generated typescript delcaration files (.d.ts).
It also exports the Honeybadger object from @honeybadger-io/js.
This simplifies the component's integration from:

import Honeybadger from '@honeybadger-io/js
import ErrorBoundary from '@honeybadger-io/react'

to:

import {Honeybadger, HoneybadgerErrorBoundary} from '@honeybadger-io/react'

Related PRs

docs - https://github.com/honeybadger-io/docs/pull/141

Todos

  • Transform to TS
  • New rollup config
  • Remove unused dependencies
  • Generate .d.ts files automatically
  • Export Honeybadger from @honeybadger-js - BREAKING CHANGE
  • Commit example project in typescript
  • Tests
  • Documentation
  • Changelog Entry (unreleased)

Steps to Test or Reproduce

I tested this by creating a react app with the typescript template.
I then installed the honeybadger-react package and imported the component slightly differently.

> npx create-react-app honeybadger-react-ts-app --template typescript
> cd honeybadger-react-ts-app
> npm i "[email protected]:honeybadger-io/honeybadger-react.git#ts"
  1. Open src/index.tsx and do:
import {Honeybadger, HoneybadgerErrorBoundary} from '@honeybadger-io/react';

const apikey = (
    process.env.REACT_APP_HONEYBADGER_API_KEY ||
    prompt('Enter the API key for your Honeybadger project:') as string
);

const honeybadgerClient = Honeybadger.configure({
    apiKey: apikey,
    environment: 'production'
})

ReactDOM.render(
    <HoneybadgerErrorBoundary honeybadger={honeybadgerClient}>
    <App />
    </HoneybadgerErrorBoundary>,
  document.getElementById('root')
);

…el, remove manually generated d.ts, new rollup config and cleanup, export honeybadger from js, new version number (patch)
@subzero10 subzero10 self-assigned this Sep 18, 2021
@@ -9,7 +9,7 @@
"url": "git+ssh:https://[email protected]/honeybadger-io/honeybadger-react.git"
},
"main": "dist/honeybadger-react.cjs.js",
"types": "./honeybadger-react.d.ts",
"types": "./dist/index.d.ts",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type definitions are now generated dynamically when installing the package! 🥳

@@ -1,6 +1,6 @@
{
"name": "@honeybadger-io/react",
"version": "1.0.2",
"version": "2.0.0",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to bump the major version because we are introducing a breaking change. See details in PR description and we can discuss this further.

@@ -1,30 +1,27 @@
import babel from 'rollup-plugin-babel'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A number of these deps were unnecessary so I did some cleanup.

@@ -0,0 +1,9 @@
import Honeybadger from "@honeybadger-io/js"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exporting core Honeybadger from @honeybadger-op/js to make react integration simpler.

@subzero10 subzero10 linked an issue Sep 20, 2021 that may be closed by this pull request
We try to stick to the approved subset of headings defined by keepachangelog (https://keepachangelog.com/en/1.0.0/). I added a prefix to call out the breaking change.
Copy link
Member

@joshuap joshuap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks! Feel free to merge this when ready. I'll cut the release and then merge the docs PR.

@subzero10
Copy link
Member Author

Looks good, thanks! Feel free to merge this when ready. I'll cut the release and then merge the docs PR.

👌 Will do another round of testing (probably tomorrow) and merge.

@subzero10 subzero10 merged commit d4f2044 into master Sep 21, 2021
@subzero10
Copy link
Member Author

@joshuap This is ready to release.

@joshuap
Copy link
Member

joshuap commented Sep 24, 2021

2.0.0 has been released

@subzero10
Copy link
Member Author

2.0.0 has been released

Awesome! Will test the release asap.

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

Successfully merging this pull request may close these issues.

Transform to Typescript
2 participants