From eb3b5bf48764a0d54d8e85b49bd3bb500179b4e8 Mon Sep 17 00:00:00 2001 From: tycho Date: Tue, 13 Aug 2024 14:25:57 +0800 Subject: [PATCH] fix(types): add fallback stub for DOM types when DOM lib is absent --- packages/runtime-dom/src/index.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/runtime-dom/src/index.ts b/packages/runtime-dom/src/index.ts index 95f27353a72..d48f138f6f6 100644 --- a/packages/runtime-dom/src/index.ts +++ b/packages/runtime-dom/src/index.ts @@ -33,9 +33,17 @@ import type { vShow } from './directives/vShow' import type { VOnDirective } from './directives/vOn' import type { VModelDirective } from './directives/vModel' +/** + * This is a stub implementation to prevent the need to use dom types. + * + * To enable proper types, add `"dom"` to `"lib"` in your `tsconfig.json`. + */ +type DomStub = {} +type DomType = typeof globalThis extends { window: unknown } ? T : DomStub + declare module '@vue/reactivity' { export interface RefUnwrapBailTypes { - runtimeDOMBailTypes: Node | Window + runtimeDOMBailTypes: DomType } }