From fee669764fbf475adce9e47a7a73b4937ab31ffc Mon Sep 17 00:00:00 2001 From: Tycho Date: Tue, 13 Aug 2024 22:06:10 +0800 Subject: [PATCH] fix(types): add fallback stub for DOM types when DOM lib is absent (#11598) --- 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 344cbf37584..64bfacef22f 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 } }