From ee9e0d867b379c32bb0139f8d2820d34cf9146e5 Mon Sep 17 00:00:00 2001 From: AI-DEV-BOT Date: Fri, 29 May 2026 23:42:24 +0900 Subject: [PATCH] refactor(core): replace public any types with unknown --- packages/core/src/types/error.ts | 4 +--- packages/core/src/types/misc.ts | 4 +--- packages/core/src/types/samplingcontext.ts | 4 +--- packages/core/src/types/stackframe.ts | 8 ++------ packages/core/src/types/user.ts | 4 +--- packages/core/src/utils/aggregate-errors.ts | 4 ++-- packages/core/src/utils/is.ts | 10 ++++++---- 7 files changed, 14 insertions(+), 24 deletions(-) diff --git a/packages/core/src/types/error.ts b/packages/core/src/types/error.ts index ca92b924b933..df67cf898f41 100644 --- a/packages/core/src/types/error.ts +++ b/packages/core/src/types/error.ts @@ -2,7 +2,5 @@ * Just an Error object with arbitrary attributes attached to it. */ export interface ExtendedError extends Error { - // TODO: fix in v11, convert any to unknown - // eslint-disable-next-line @typescript-eslint/no-explicit-any - [key: string]: any; + [key: string]: unknown; } diff --git a/packages/core/src/types/misc.ts b/packages/core/src/types/misc.ts index 8a53f12781e2..162e49b4b67f 100644 --- a/packages/core/src/types/misc.ts +++ b/packages/core/src/types/misc.ts @@ -4,9 +4,7 @@ import type { QueryParams } from './request'; * Data extracted from an incoming request to a node server */ export interface ExtractedNodeRequestData { - // TODO: fix in v11, convert any to unknown - // eslint-disable-next-line @typescript-eslint/no-explicit-any - [key: string]: any; + [key: string]: unknown; /** Specific headers from the request */ headers?: { [key: string]: string }; diff --git a/packages/core/src/types/samplingcontext.ts b/packages/core/src/types/samplingcontext.ts index a46d9efaba67..19e2e3e2435f 100644 --- a/packages/core/src/types/samplingcontext.ts +++ b/packages/core/src/types/samplingcontext.ts @@ -6,9 +6,7 @@ import type { SpanAttributes } from './span'; * Context data passed by the user when starting a transaction, to be used by the tracesSampler method. */ export interface CustomSamplingContext { - // TODO: fix in v11, convert any to unknown - // eslint-disable-next-line @typescript-eslint/no-explicit-any - [key: string]: any; + [key: string]: unknown; } /** diff --git a/packages/core/src/types/stackframe.ts b/packages/core/src/types/stackframe.ts index 9afb1d440d43..5f4b8b0e762b 100644 --- a/packages/core/src/types/stackframe.ts +++ b/packages/core/src/types/stackframe.ts @@ -13,11 +13,7 @@ export interface StackFrame { in_app?: boolean; instruction_addr?: string; addr_mode?: string; - // TODO: fix in v11, convert any to unknown - // eslint-disable-next-line @typescript-eslint/no-explicit-any - vars?: { [key: string]: any }; + vars?: { [key: string]: unknown }; debug_id?: string; - // TODO: fix in v11, convert any to unknown - // eslint-disable-next-line @typescript-eslint/no-explicit-any - module_metadata?: any; + module_metadata?: Record; } diff --git a/packages/core/src/types/user.ts b/packages/core/src/types/user.ts index ff917ffbd344..cb849acdab43 100644 --- a/packages/core/src/types/user.ts +++ b/packages/core/src/types/user.ts @@ -2,9 +2,7 @@ * An interface describing a user of an application or a handled request. */ export interface User { - // TODO: fix in v11, convert any to unknown - // eslint-disable-next-line @typescript-eslint/no-explicit-any - [key: string]: any; + [key: string]: unknown; id?: string | number; ip_address?: string | null; email?: string; diff --git a/packages/core/src/utils/aggregate-errors.ts b/packages/core/src/utils/aggregate-errors.ts index 048570cb1f05..947a998f4970 100644 --- a/packages/core/src/utils/aggregate-errors.ts +++ b/packages/core/src/utils/aggregate-errors.ts @@ -57,7 +57,7 @@ function aggregateExceptionsFromError( // Recursively call this function in order to walk down a chain of errors if (isInstanceOf(error[key], Error)) { applyExceptionGroupFieldsForParentException(exception, exceptionId, error); - const newException = exceptionFromErrorImplementation(parser, error[key] as Error); + const newException = exceptionFromErrorImplementation(parser, error[key]); const newExceptionId = newExceptions.length; applyExceptionGroupFieldsForChildException(newException, key, newExceptionId, exceptionId); newExceptions = aggregateExceptionsFromError( @@ -78,7 +78,7 @@ function aggregateExceptionsFromError( error.errors.forEach((childError, i) => { if (isInstanceOf(childError, Error)) { applyExceptionGroupFieldsForParentException(exception, exceptionId, error); - const newException = exceptionFromErrorImplementation(parser, childError as Error); + const newException = exceptionFromErrorImplementation(parser, childError); const newExceptionId = newExceptions.length; applyExceptionGroupFieldsForChildException(newException, `errors[${i}]`, newExceptionId, exceptionId); newExceptions = aggregateExceptionsFromError( diff --git a/packages/core/src/utils/is.ts b/packages/core/src/utils/is.ts index 98000b309ab3..f78b25a170a7 100644 --- a/packages/core/src/utils/is.ts +++ b/packages/core/src/utils/is.ts @@ -184,11 +184,13 @@ export function isSyntheticEvent(wat: unknown): boolean { * @param base A constructor to be used in a check. * @returns A boolean representing the result. */ -// TODO: fix in v11, convert any to unknown -// export function isInstanceOf(wat: unknown, base: { new (...args: any[]): T }): wat is T { -export function isInstanceOf(wat: any, base: any): wat is T { +type Constructor = { new (...args: never[]): T }; + +export function isInstanceOf(wat: unknown, base: Constructor): wat is T; +export function isInstanceOf(wat: unknown, base: unknown): boolean; +export function isInstanceOf(wat: unknown, base: unknown): wat is T { try { - return wat instanceof base; + return wat instanceof (base as Constructor); } catch { return false; }