Skip to content

Commit f5e1e51

Browse files
SebastiaanNijlandkamilogorek
authored andcommitted
chore: replace several instances of any (getsentry#2264)
* chore: replace several instances of any * fix: make sure build works
1 parent 08c703d commit f5e1e51

File tree

6 files changed

+12
-17
lines changed

6 files changed

+12
-17
lines changed

packages/browser/src/helpers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { captureException, getCurrentHub, withScope } from '@sentry/core';
2-
import { Event as SentryEvent, Mechanism, WrappedFunction } from '@sentry/types';
2+
import { Event as SentryEvent, Mechanism, Scope, WrappedFunction } from '@sentry/types';
33
import { addExceptionMechanism, addExceptionTypeValue, htmlTreeAsString, normalize } from '@sentry/utils';
44

55
const debounceDuration: number = 1000;
@@ -92,7 +92,7 @@ export function wrap(
9292
} catch (ex) {
9393
ignoreNextOnError();
9494

95-
withScope(scope => {
95+
withScope((scope: Scope) => {
9696
scope.addEventProcessor((event: SentryEvent) => {
9797
const processedEvent = { ...event };
9898

packages/browser/src/integrations/breadcrumbs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ export class Breadcrumbs implements Integration {
468468
});
469469

470470
if ('onreadystatechange' in xhr && typeof xhr.onreadystatechange === 'function') {
471-
fill(xhr, 'onreadystatechange', function(original: () => void): void {
471+
fill(xhr, 'onreadystatechange', function(original: () => void): Function {
472472
return wrap(
473473
original,
474474
{

packages/browser/src/sdk.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,5 @@ export function close(timeout?: number): PromiseLike<boolean> {
163163
* @returns The result of wrapped function call.
164164
*/
165165
export function wrap(fn: Function): any {
166-
// tslint:disable-next-line: no-unsafe-any
167166
return internalWrap(fn)();
168167
}

packages/core/src/baseclient.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,8 @@ export abstract class BaseClient<B extends Backend, O extends Options> implement
359359
}
360360

361361
const beforeSendResult = beforeSend(prepared, hint);
362-
if ((typeof beforeSendResult as any) === 'undefined') {
362+
// tslint:disable-next-line:strict-type-predicates
363+
if (typeof beforeSendResult === 'undefined') {
363364
logger.error('`beforeSend` method has to return `null` or a valid event.');
364365
} else if (isThenable(beforeSendResult)) {
365366
this._handleAsyncBeforeSend(beforeSendResult as PromiseLike<Event | null>, resolve, reject);

packages/core/src/integrations/inboundfilters.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ export class InboundFilters implements Integration {
8787
}
8888

8989
try {
90-
// tslint:disable-next-line:no-unsafe-any
91-
return (event as any).exception.values[0].type === 'SentryError';
90+
return event && event.exception && event.exception.values && event.exception.values[0] && event.exception.values[0].type === 'SentryError' || false;
9291
} catch (_oO) {
9392
return false;
9493
}
@@ -147,8 +146,7 @@ export class InboundFilters implements Integration {
147146
}
148147
if (event.exception) {
149148
try {
150-
// tslint:disable-next-line:no-unsafe-any
151-
const { type, value } = (event as any).exception.values[0];
149+
const { type = '', value = '' } = event.exception.values && event.exception.values[0] || {};
152150
return [`${value}`, `${type}: ${value}`];
153151
} catch (oO) {
154152
logger.error(`Cannot extract message for event ${getEventDescription(event)}`);
@@ -162,14 +160,12 @@ export class InboundFilters implements Integration {
162160
private _getEventFilterUrl(event: Event): string | null {
163161
try {
164162
if (event.stacktrace) {
165-
// tslint:disable:no-unsafe-any
166-
const frames = (event as any).stacktrace.frames;
167-
return frames[frames.length - 1].filename;
163+
const frames = event.stacktrace.frames;
164+
return frames && frames[frames.length - 1].filename || null;
168165
}
169166
if (event.exception) {
170-
// tslint:disable:no-unsafe-any
171-
const frames = (event as any).exception.values[0].stacktrace.frames;
172-
return frames[frames.length - 1].filename;
167+
const frames = event.exception.values && event.exception.values[0].stacktrace && event.exception.values[0].stacktrace.frames;
168+
return frames && frames[frames.length - 1].filename || null;
173169
}
174170
return null;
175171
} catch (oO) {

packages/integrations/src/rewriteframes.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ export class RewriteFrames implements Integration {
7474

7575
if (exception) {
7676
try {
77-
// tslint:disable-next-line:no-unsafe-any
78-
return (exception as any).values[0].stacktrace.frames;
77+
return exception.values && exception.values[0].stacktrace && exception.values[0].stacktrace.frames;
7978
} catch (_oO) {
8079
return undefined;
8180
}

0 commit comments

Comments
 (0)