-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add basic TypeScript types (#26)
* feat: Add basic TypeScript types I do not expect these to be completely accurate. However, they should be a decent starting point for further discussion! * feat: Add LEVEL to the types for convenience * fix: useRollbarConfiguration's return to void * feat(ts): Improvements on typing and formatting * feat(ts): Add types to package.json
- Loading branch information
1 parent
9e940f6
commit ad8f667
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { Component, ReactNode } from "react"; | ||
import Rollbar, { Callback } from "rollbar"; | ||
|
||
export const LEVEL_DEBUG = "debug"; | ||
export const LEVEL_INFO = "info"; | ||
export const LEVEL_WARN = "warn"; | ||
export const LEVEL_ERROR = "error"; | ||
export const LEVEL_CRITICAL = "critical"; | ||
export type LEVEL = | ||
| typeof LEVEL_DEBUG | ||
| typeof LEVEL_INFO | ||
| typeof LEVEL_WARN | ||
| typeof LEVEL_ERROR | ||
| typeof LEVEL_CRITICAL; | ||
|
||
export interface ErrorBoundaryProps { | ||
children: ReactNode; | ||
fallbackUI?: ReactNode; | ||
errorMessage?: string | (() => string); | ||
extra?: | ||
| Record<string | number, unknown> | ||
| (() => Record<string | number, unknown>); | ||
level?: LEVEL | (() => LEVEL); | ||
callback?: Callback<any>; | ||
} | ||
|
||
interface ErrorBoundaryState { | ||
hasError: boolean; | ||
error: Error | null; | ||
} | ||
|
||
export class ErrorBoundary extends Component< | ||
ErrorBoundaryProps, | ||
ErrorBoundaryState | ||
> { | ||
resetError: () => void; | ||
} | ||
export class RollbarContext extends Component<{ | ||
children: ReactNode; | ||
context?: string; | ||
}> {} | ||
export function useRollbar(): Rollbar; | ||
export function useRollbarConfiguration(config: Rollbar.Configuration): void; | ||
export function useRollbarContext(ctx?: string, isLayout?: boolean): void; | ||
export function useRollbarPerson(person: object): void; | ||
export function useRollbarCaptureEvent(metadata: object, level?: LEVEL): void; | ||
export function isValidLevel(level: LEVEL): boolean; | ||
|
||
export function historyContext( | ||
rollbar: Rollbar, | ||
args: { | ||
formatter: (location: string, action: string) => string; | ||
filter: (location: string, action: string) => boolean; | ||
} | ||
): ( | ||
v4Location: { | ||
action: string; | ||
filter: (location: string, action: string) => boolean; | ||
}, | ||
v4action: string | ||
) => void; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
"directories": { | ||
"lib": "dist" | ||
}, | ||
"types": "index.d.ts", | ||
"files": [ | ||
"dist", | ||
"lib", | ||
|