8000 ref(core): Support TS4.4 exactOptionalPropertyTypes in Options and Ba… · GinMu/sentry-javascript@7d2fa39 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7d2fa39

Browse files
quisidokamilogorek
authored andcommitted
ref(core): Support TS4.4 exactOptionalPropertyTypes in Options and BaseBackend
1 parent d3ca7a8 commit 7d2fa39

File tree

2 files changed

+37
-31
lines changed

2 files changed

+37
-31
lines changed

packages/core/src/basebackend.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,18 @@ export abstract class BaseBackend<O extends Options> implements Backend {
7676
* @inheritDoc
7777
*/
7878
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
79-
public eventFromException(_exception: any, _hint?: EventHint): PromiseLike<Event> {
79+
public eventFromException(_exception: any, _hint?: EventHint | undefined): PromiseLike<Event> {
8080
throw new SentryError('Backend has to implement `eventFromException` method');
8181
}
8282

8383
/**
8484
* @inheritDoc
8585
*/
86-
public eventFromMessage(_message: string, _level?: Severity, _hint?: EventHint): PromiseLike<Event> {
86+
public eventFromMessage(
87+
_message: string,
88+
_level?: Severity | undefined,
89+
_hint?: EventHint | undefined,
90+
): PromiseLike<Event> {
8791
throw new SentryError('Backend has to implement `eventFromMessage` method');
8892
}
8993

packages/types/src/options.ts

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,88 +12,88 @@ export interface Options {
1212
/**
1313
* Enable debug functionality in the SDK itself
1414
*/
15-
debug?: boolean;
15+
debug?: boolean | undefined;
1616

1717
/**
1818
* Specifies whether this SDK should activate and send events to Sentry.
1919
* Disabling the SDK reduces all overhead from instrumentation, collecting
2020
* breadcrumbs and capturing events. Defaults to true.
2121
*/
22-
enabled?: boolean;
22+
enabled?: boolean | undefined;
2323

2424
/**
2525
* The Dsn used to connect to Sentry and identify the project. If omitted, the
2626
* SDK will not send any data to Sentry.
2727
*/
28-
dsn?: string;
28+
dsn?: string | undefined;
2929

3030
/**
3131
* If this is set to false, default integrations will not be added, otherwise this will internally be set to the
3232
* recommended default integrations.
3333
* TODO: We should consider changing this to `boolean | Integration[]`
3434
*/
35-
defaultIntegrations?: false | Integration[];
35+
defaultIntegrations?: false | Integration[] | undefined;
3636

3737
/**
3838
* List of integrations that should be installed after SDK was initialized.
3939
* Accepts either a list of integrations or a function that receives
4040
* default integrations and returns a new, updated list.
4141
*/
42-
integrations?: Integration[] | ((integrations: Integration[]) => Integration[]);
42+
integrations?: Integration[] | ((integrations: Integration[]) => Integration[]) | undefined;
4343

4444
/**
4545
* A pattern for error messages which should not be sent to Sentry.
4646
* By default, all errors will be sent.
4747
*/
48-
ignoreErrors?: Array<string | RegExp>;
48+
ignoreErrors?: Array<string | RegExp> | undefined;
4949

5050
/**
5151
* Transport object that should be used to send events to Sentry
5252
*/
53-
transport?: TransportClass<Transport>;
53+
transport?: TransportClass<Transport> | undefined;
5454

5555
/**
5656
* Options for the default transport that the SDK uses.
5757
*/
58-
transportOptions?: TransportOptions;
58+
transportOptions?: TransportOptions | undefined;
5959

6060
/**
6161
* A URL to an envelope tunnel endpoint. An envelope tunnel is an HTTP endpoint
6262
* that accepts Sentry envelopes for forwarding. This can be used to force data
6363
* through a custom server independent of the type of data.
6464
*/
65-
tunnel?: string;
65+
tunnel?: string | undefined;
6666

6767
/**
6868
* The release identifier used when uploading respective source maps. Specify
6969
* this value to allow Sentry to resolve the correct source maps when
7070
* processing events.
7171
*/
72-
release?: string;
72+
release?: string | undefined;
7373

7474
/** The current environment of your application (e.g. "production"). */
75-
environment?: string;
75+
environment?: string | undefined;
7676

7777
/** Sets the distribution for all events */
78-
dist?: string;
78+
dist?: string | undefined;
7979

8080
/**
8181
* The maximum number of breadcrumbs sent with events. Defaults to 100.
8282
* Values over 100 will be ignored and 100 used instead.
8383
*/
84-
maxBreadcrumbs?: number;
84+
maxBreadcrumbs?: number | undefined;
8585

8686
/** Console logging verbosity for the SDK Client. */
87-
logLevel?: LogLevel;
87+
logLevel?: LogLevel | undefined;
8888

8989
/** A global sample rate to apply to all events (0 - 1). */
90-
sampleRate?: number;
90+
sampleRate?: number | undefined;
9191

9292
/** Attaches stacktraces to pure capture message / log integrations */
93-
attachStacktrace?: boolean;
93+
attachStacktrace?: boolean | undefined;
9494

9595
/** Maxium number of chars a single value can have before it will be truncated. */
96-
maxValueLength?: number;
96+
maxValueLength?: number | undefined;
9797

9898
/**
9999
* Maximum number of levels that normalization algorithm will traverse in objects and arrays.
@@ -104,7 +104,7 @@ export interface Options {
104104
* - `extra`
105105
* Defaults to `3`. Set to `0` to disable.
106106
*/
107-
normalizeDepth?: number;
107+
normalizeDepth?: number | undefined;
108108

109109
/**
110110
* Controls how many milliseconds to wait before shutting down. The default is
@@ -113,7 +113,7 @@ export interface Options {
113113
* high can cause the application to block for users with network connectivity
114114
* problems.
115115
*/
116-
shutdownTimeout?: number;
116+
shutdownTimeout?: number | undefined;
117117

118118
/**
119119
* Sample rate to determine trace sampling.
@@ -124,31 +124,33 @@ export interface Options {
124124
* Tracing is enabled if either this or `tracesSampler` is defined. If both are defined, `tracesSampleRate` is
125125
* ignored.
126126
*/
127-
tracesSampleRate?: number;
127+
tracesSampleRate?: number | undefined;
128128

129129
/**
130130
* A flag enabling Sessions Tracking feature.
131131
* By default, Sessions Tracking is enabled.
132132
*/
133-
autoSessionTracking?: boolean;
133+
autoSessionTracking?: boolean | undefined;
134134

135135
/**
136136
* Initial data to populate scope.
137137
*/
138-
initialScope?: CaptureContext;
138+
initialScope?: CaptureContext | undefined;
139139

140140
/**
141141
* Set of metadata about the SDK that can be internally used to enhance envelopes and events,
142142
* and provide additional data about every request.
143143
* */
144-
_metadata?: SdkMetadata;
144+
_metadata?: SdkMetadata | undefined;
145145

146146
/**
147147
* Options which are in beta, or otherwise not guaranteed to be stable.
148148
*/
149-
_experiments?: {
150-
[key: string]: any;
151-
};
149+
_experiments?:
150+
| {
151+
[key: string]: any;
152+
}
153+
| undefined;
152154

153155
/**
154156
* Function to compute tracing sample rate dynamically and filter unwanted traces.
@@ -162,7 +164,7 @@ export interface Options {
162164
* @returns A sample rate between 0 and 1 (0 drops the trace, 1 guarantees it will be sent). Returning `true` is
163165
* equivalent to returning 1 and returning `false` is equivalent to returning 0.
164166
*/
165-
tracesSampler?(samplingContext: SamplingContext): number | boolean;
167+
tracesSampler?: undefined | ((samplingContext: SamplingContext) => number | boolean);
166168

167169
/**
168170
* A callback invoked during event submission, allowing to optionally modify
@@ -176,7 +178,7 @@ export interface Options {
176178
* @param hint May contain additional information about the original exception.
177179
* @returns A new event that will be sent | null.
178180
*/
179-
beforeSend?(event: Event, hint?: EventHint): PromiseLike<Event | null> | Event | null;
181+
beforeSend?: undefined | ((event: Event, hint?: EventHint) => PromiseLike<Event | null> | Event | null);
180182

181183
/**
182184
* A callback invoked when adding a breadcrumb, allowing to optionally modify
@@ -189,5 +191,5 @@ export interface Options {
189191
* @param breadcrumb The breadcrumb as created by the SDK.
190192
* @returns The breadcrumb that will be added | null.
191193
*/
192-
beforeBreadcrumb?(breadcrumb: Breadcrumb, hint?: BreadcrumbHint): Breadcrumb | null;
194+
beforeBreadcrumb?: undefined | ((breadcrumb: Breadcrumb, hint?: BreadcrumbHint) => Breadcrumb | null);
193195
}

0 commit comments

Comments
 (0)
0