fix: Prevent type errors when optional `@opentelemetry/api` dependency isn't installe...
authorSimon H <5968653+dummdidumm@users.noreply.github.com>
Thu, 20 Nov 2025 10:27:13 +0000 (11:27 +0100)
committerGitHub <noreply@github.com>
Thu, 20 Nov 2025 10:27:13 +0000 (18:27 +0800)
* fix: Prevent type errors when optional `@opentelemetry/api` dependency isn't installed

Fixes #14774
Better alternative to #14848

* Apply suggestion from @teemingc

---------

Co-authored-by: Tee Ming <chewteeming01@gmail.com>
.changeset/flat-steaks-yawn.md [new file with mode: 0644]
packages/kit/src/exports/public.d.ts
packages/kit/types/index.d.ts

diff --git a/.changeset/flat-steaks-yawn.md b/.changeset/flat-steaks-yawn.md
new file mode 100644 (file)
index 0000000..0a2e323
--- /dev/null
@@ -0,0 +1,5 @@
+---
+'@sveltejs/kit': patch
+---
+
+fix: prevent type errors when optional `@opentelemetry/api` dependency isn't installed
index 39174438f805b887580e5ed4d25093486b23531c..21ed3e6cda0006c08a5c150a40afb94ed1921d69 100644 (file)
@@ -25,10 +25,12 @@ import {
        LayoutParams as AppLayoutParams,
        ResolvedPathname
 } from '$app/types';
-import { Span } from '@opentelemetry/api';
 
 export { PrerenderOption } from '../types/private.js';
 
+// @ts-ignore this is an optional peer dependency so could be missing. Written like this so dts-buddy preserves the ts-ignore
+type Span = import('@opentelemetry/api').Span;
+
 /**
  * [Adapters](https://svelte.dev/docs/kit/adapters) are responsible for taking the production build and turning it into something that can be deployed to a platform of your choosing.
  */
index 548bc7a78d83addfb37cf145243c95425549b35d..35b387405f53fcf56aaf9e865e780f4971075fda 100644 (file)
@@ -5,7 +5,9 @@ declare module '@sveltejs/kit' {
        import type { SvelteConfig } from '@sveltejs/vite-plugin-svelte';
        import type { StandardSchemaV1 } from '@standard-schema/spec';
        import type { RouteId as AppRouteId, LayoutParams as AppLayoutParams, ResolvedPathname } from '$app/types';
-       import type { Span } from '@opentelemetry/api';
+       // @ts-ignore this is an optional peer dependency so could be missing. Written like this so dts-buddy preserves the ts-ignore
+       type Span = import('@opentelemetry/api').Span;
+
        /**
         * [Adapters](https://svelte.dev/docs/kit/adapters) are responsible for taking the production build and turning it into something that can be deployed to a platform of your choosing.
         */