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

feat: Add basic TypeScript types #26

Merged
merged 5 commits into from
Jan 25, 2022
Merged

Conversation

quinnturner
Copy link
Contributor

@quinnturner quinnturner commented Jan 7, 2022

Description of the change

I do not expect these to be completely accurate.
However, they should be a decent starting point for further discussion!

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Maintenance
  • New release

Related issues

Shortcut stories and GitHub issues (delete irrelevant)

Checklists

Development

  • Lint rules pass locally
  • The code changed/added as part of this pull request has been covered with tests
  • All tests related to the changed code pass in development

Code review

  • This pull request has a descriptive title and information useful to a reviewer. There may be a screenshot or screencast attached
  • "Ready for review" label attached to the PR and reviewers assigned
  • Issue from task tracker has a link to this pull request
  • Changes have been reviewed by at least one other engineer

I do not expect these to be completely accurate.
However, they should be a decent starting point for further discussion!
export function useRollbarCaptureEvent(metadata: object, level?: LEVEL): void;
export function isValidLevel(): boolean;

export function historyContext(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am unsure about most of historyContext, especially filter, formatter, and v4xs

Copy link
Contributor Author

@quinnturner quinnturner Jan 11, 2022

Choose a reason for hiding this comment

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

Improved them but still not 100% confident

index.d.ts Outdated
children: ReactNode;
fallbackUI?: ReactNode
errorMessage?: string | (() => string)
extra?: Record<string | number, unknown> | (() => Record<string | number, unknown>)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am unsure about extra

index.d.ts Outdated Show resolved Hide resolved
@calvinf
Copy link

calvinf commented Jan 25, 2022

It would be very helpful to have types as part of the module.

I found one component missing a type when I tried to use this myself - Provider.

Here's an implementation that worked for me:

type ProviderPropTypes = {
    Rollbar?: Rollbar
    config: Rollbar.Configuration
    instance?: Rollbar
  }

  export class Provider extends Component<ProviderPropTypes> {}

For anyone hacking this into their own project manually, you'll want to wrap the index.d.ts from this PR:

declare module '@rollbar/react' {
 // types go here
}

And put it in a place that the types are picked up, e.g. if you have typeRoots in your tsconfig.json

{
  "typeRoots": ["./types/"]
}

Then put the file as rollbar-react.d.ts in the types folder.

@waltjones waltjones self-requested a review January 25, 2022 22:59
Copy link
Contributor

@waltjones waltjones left a comment

Choose a reason for hiding this comment

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

@quinnturner thank you.

Merging this, and welcoming follow up PRs to fix any remaining issues.

@waltjones waltjones merged commit ad8f667 into rollbar:main Jan 25, 2022
@quinnturner quinnturner deleted the typing branch January 25, 2022 23:02
@quinnturner quinnturner mentioned this pull request Jan 25, 2022
5 tasks
@quinnturner
Copy link
Contributor Author

@waltjones @calvinf, I added types for Provider here: #27

@waltjones
Copy link
Contributor

@quinnturner @calvinf v0.9.0 is released now with both PRs included.

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

Successfully merging this pull request may close these issues.

3 participants