From ad21a0e6176aaf51afc8783201ea2f09b54def87 Mon Sep 17 00:00:00 2001 From: Alec Mev Date: Sun, 30 Jun 2024 22:19:12 +0100 Subject: [PATCH] fix(instrumentation): Fix optional property types TypeScript emits InstrumentationNodeModuleDefinition with " | undefined" for some reason, making it incompatible with InstrumentationModuleDefinition under exactOptionalPropertyTypes. --- CHANGELOG.md | 1 + .../packages/opentelemetry-instrumentation/src/types.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 40b59d2336..1d7493899a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ For experimental package changes, see the [experimental CHANGELOG](experimental/ * fix(sdk-node): avoid spurious diag errors for unknown OTEL_NODE_RESOURCE_DETECTORS values [#4879](https://github.com/open-telemetry/opentelemetry-js/pull/4879) @trentm * deps(opentelemetry-instrumentation): Bump `shimmer` types to 1.2.0 [#4865](https://github.com/open-telemetry/opentelemetry-js/pull/4865) @lforst +* fix(instrumentation): Fix optional property types [#4833](https://github.com/open-telemetry/opentelemetry-js/pull/4833) @alecmev ### :books: (Refine Doc) diff --git a/experimental/packages/opentelemetry-instrumentation/src/types.ts b/experimental/packages/opentelemetry-instrumentation/src/types.ts index 2fa567ff01..b58054ac0d 100644 --- a/experimental/packages/opentelemetry-instrumentation/src/types.ts +++ b/experimental/packages/opentelemetry-instrumentation/src/types.ts @@ -136,11 +136,15 @@ export interface InstrumentationModuleDefinition { /** Method to patch the instrumentation */ // eslint-disable-next-line @typescript-eslint/no-explicit-any - patch?: (moduleExports: any, moduleVersion?: string) => any; + patch?: + | ((moduleExports: any, moduleVersion?: string | undefined) => any) + | undefined; /** Method to unpatch the instrumentation */ // eslint-disable-next-line @typescript-eslint/no-explicit-any - unpatch?: (moduleExports: any, moduleVersion?: string) => void; + unpatch?: + | ((moduleExports: any, moduleVersion?: string | undefined) => void) + | undefined; } /**