Skip to content

Commit c3c41fc

Browse files
committed
fix a bunch of any vs unknown types problems
1 parent 8632fb6 commit c3c41fc

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

packages/core/src/baseclient.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -405,16 +405,16 @@ export abstract class BaseClient<B extends Backend, O extends Options> implement
405405
...(b.data && {
406406
data: normalize(b.data, depth, maxBreadth),
407407
}),
408-
})),
408+
})) as Event['breadcrumbs'],
409409
}),
410410
...(event.user && {
411-
user: normalize(event.user, depth, maxBreadth),
411+
user: normalize(event.user, depth, maxBreadth) as Event['user'],
412412
}),
413413
...(event.contexts && {
414-
contexts: normalize(event.contexts, depth, maxBreadth),
414+
contexts: normalize(event.contexts, depth, maxBreadth) as Event['contexts'],
415415
}),
416416
...(event.extra && {
417-
extra: normalize(event.extra, depth, maxBreadth),
417+
extra: normalize(event.extra, depth, maxBreadth) as Event['extra'],
418418
}),
419419
};
420420
// event.contexts.trace stores information about a Transaction. Similarly,
@@ -425,8 +425,8 @@ export abstract class BaseClient<B extends Backend, O extends Options> implement
425425
// so this block overwrites the normalized event to add back the original
426426
// Transaction information prior to normalization.
427427
if (event.contexts && event.contexts.trace) {
428-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
429-
normalized.contexts.trace = event.contexts.trace;
428+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
429+
normalized.contexts!.trace = event.contexts.trace;
430430
}
431431

432432
event.sdkProcessingMetadata = { ...event.sdkProcessingMetadata, baseClientNormalized: true };

packages/integrations/src/offline.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export class Offline implements Integration {
109109
* @param event an event
110110
*/
111111
private async _cacheEvent(event: Event): Promise<Event> {
112-
return this.offlineEventStore.setItem<Event>(uuid4(), normalize(event));
112+
return this.offlineEventStore.setItem<Event>(uuid4(), normalize(event) as Event);
113113
}
114114

115115
/**

packages/utils/src/normalize.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { memoBuilder, MemoFunc } from './memo';
55
import { convertToPlainObject } from './object';
66
import { getFunctionName } from './stacktrace';
77

8-
type UnknownMaybeWithToJson = unknown & { toJSON?: () => string };
98
type Prototype = { constructor: (...args: unknown[]) => unknown };
109

1110
/**
@@ -27,18 +26,18 @@ type Prototype = { constructor: (...args: unknown[]) => unknown };
2726
* object in the normallized output..
2827
* @returns A normalized version of the object, or `"**non-serializable**"` if any errors are thrown during normalization.
2928
*/
30-
export function normalize(input: unknown, depth: number = +Infinity, maxProperties: number = +Infinity): any {
29+
export function normalize(input: unknown, depth: number = +Infinity, maxProperties: number = +Infinity): unknown {
3130
try {
3231
// since we're at the outermost level, there is no key
33-
return visit('', input as UnknownMaybeWithToJson, depth, maxProperties);
32+
return visit('', input, depth, maxProperties);
3433
} catch (err) {
3534
return { ERROR: `**non-serializable** (${err})` };
3635
}
3736
}
3837

3938
/** JSDoc */
4039
export function normalizeToSize<T>(
41-
object: { [key: string]: any },
40+
object: { [key: string]: unknown },
4241
// Default Node.js REPL depth
4342
depth: number = 3,
4443
// 100kB, as 200kB is max payload size, so half sounds reasonable
@@ -68,7 +67,7 @@ export function visit(
6867
depth: number = +Infinity,
6968
maxProperties: number = +Infinity,
7069
memo: MemoFunc = memoBuilder(),
71-
): Primitive | unknown[] | { [key: string]: unknown } {
70+
): Primitive | { [key: string]: unknown } {
7271
const [memoize, unmemoize] = memo;
7372

7473
// if the value has a `toJSON` method, bail and let it do the work
@@ -230,6 +229,6 @@ function utf8Length(value: string): number {
230229
}
231230

232231
/** Calculates bytes size of input object */
233-
function jsonSize(value: any): number {
232+
function jsonSize(value: unknown): number {
234233
return utf8Length(JSON.stringify(value));
235234
}

0 commit comments

Comments
 (0)