Skip to content

Commit 8e3b8bc

Browse files
chrisbobbegnprice
authored andcommitted
@sentry/react-native libdef: Move to .js.flow files
1 parent 9fe25b8 commit 8e3b8bc

File tree

3 files changed

+23
-17
lines changed

3 files changed

+23
-17
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ types/@react-navigation
88
types/react-intl.js.flow
99
types/@react-native-community/netinfo/**
1010
types/react-native-safe-area-context/**
11+
types/@sentry/react-native.js.flow
1112

1213
# These are type-tests, made up of code that gets type-checked but
1314
# never actually run. They're naturally full of dead code which

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ types/@react-navigation
88
types/react-intl.js.flow
99
types/@react-native-community/netinfo/**
1010
types/react-native-safe-area-context/**
11+
types/@sentry/react-native.js.flow
1112

1213
# Third-party code: react-native. We leave this code in the style we
1314
# received it in.

flow-typed/@sentry/react-native_v2.x.x.js renamed to types/@sentry/react-native.js.flow

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
declare module '@sentry/react-native' {
2-
declare type Primitive =
1+
/**
2+
* Types for the NPM package `@sentry/react-native`.
3+
*
4+
* @flow strict-local
5+
*/
6+
7+
type Primitive =
38
| number
49
| string
510
| boolean
@@ -17,7 +22,7 @@ declare type Primitive =
1722
// * https://github.com/getsentry/sentry-javascript/blob/f4e59bcdd/packages/types/src/options.ts
1823
//
1924
// Please add them to this declaration as (and if) they're needed.
20-
declare export type Options = {|
25+
export type Options = {|
2126
/* Do not use this in Sentry.init(). As of 1.0.9, Sentry will only be
2227
partially initialized if it's set to `false`, and anyway there's no good
2328
way to toggle it. */
@@ -74,12 +79,12 @@ declare export var Severity: $ReadOnly<{|
7479
Debug: 'debug',
7580
Critical: 'critical',
7681
|}>;
77-
declare export type SeverityType = $Values<typeof Severity>;
82+
export type SeverityType = $Values<typeof Severity>;
7883

7984
// Taken from @sentry/types/src/event.ts.
8085
//
8186
// Commented-out members have types not (yet?) present in this file.
82-
declare export type Event = {|
87+
export type Event = {|
8388
event_id?: string,
8489
message?: string,
8590
timestamp?: number,
@@ -101,16 +106,16 @@ declare export type Event = {|
101106
breadcrumbs?: Breadcrumb[],
102107
// contexts?: {| [key: string]: object |},
103108
tags?: {| [key: string]: Primitive |},
104-
extra?: {| [key: string]: any |},
109+
extra?: {| [key: string]: $FlowFixMe |},
105110
// user?: User,
106111
type?: EventType,
107112
|};
108113

109114
// Taken from @sentry/types/src/event.ts.
110-
declare export type EventType = 'transaction';
115+
export type EventType = 'transaction';
111116

112117
// Taken from @sentry/types/src/event.ts.
113-
declare export type EventHint = {|
118+
export type EventHint = {|
114119
event_id?: string,
115120
captureContext?: CaptureContext,
116121
syntheticException?: Error | null,
@@ -120,7 +125,7 @@ declare export type EventHint = {|
120125

121126
// Taken from @sentry/types/src/breadcrumb.ts.
122127
// See doc at https://develop.sentry.dev/sdk/event-payloads/breadcrumbs/
123-
declare export type Breadcrumb = {|
128+
export type Breadcrumb = {|
124129
type?: string,
125130
level?: SeverityType,
126131
event_id?: string,
@@ -133,10 +138,10 @@ declare export type Breadcrumb = {|
133138
|};
134139

135140
// Taken from @sentry/types/src/breadcrumb.ts.
136-
declare export type BreadcrumbHint = {| [key: string]: mixed |};
141+
export type BreadcrumbHint = {| [key: string]: mixed |};
137142

138143
// Taken from @sentry/types/src/hub.ts. More methods are available.
139-
declare export type Hub = {
144+
export type Hub = {
140145
getClient(): Client | typeof undefined,
141146

142147
captureException(exception: mixed, hint?: EventHint): string,
@@ -147,7 +152,7 @@ declare export type Hub = {
147152
// Really an exact object type with the commented-out properties present.
148153
// (We omit them to be lazy.) Taken from
149154
// https://github.com/getsentry/sentry-javascript/blob/6.12.0/packages/types/src/scope.ts#L16-L24
150-
declare export type ScopeContext = {
155+
export type ScopeContext = {
151156
// user: User,
152157
level: typeof Severity,
153158
// extra: Extras,
@@ -184,19 +189,19 @@ declare export class Scope {
184189
* @param key String of extra
185190
* @param extra Any kind of data. This data will be normalized.
186191
*/
187-
setExtra(key: string, extra: any): this;
192+
setExtra(key: string, extra: $FlowFixMe): this;
188193

189194
/**
190195
* Set an object that will be merged sent as extra data with the event.
191196
* @param extras Extras object to merge into current context.
192197
*/
193-
setExtras(extras: {| +[key: string]: any |}): this;
198+
setExtras(extras: {| +[key: string]: $FlowFixMe |}): this;
194199
}
195200

196-
declare export type CaptureContext = Scope | $Rest<ScopeContext, { ... }> | ((scope: Scope) => Scope);
201+
export type CaptureContext = Scope | $Rest<ScopeContext, { ... }> | ((scope: Scope) => Scope);
197202

198203
// Adapted from @sentry/types/src/client.ts, with some specialization.
199-
declare export type Client = {
204+
export type Client = {
200205
getOptions(): Options,
201206
...
202207
};
@@ -233,4 +238,3 @@ declare export function configureScope(callback: (scope: Scope) => void): void;
233238
* consulted when the event is finally captured for logging.
234239
*/
235240
declare export function withScope(callback: (scope: Scope) => void): void;
236-
}

0 commit comments

Comments
 (0)