]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(types): add fallback stub for DOM types when DOM lib is absent (#11598)
authorTycho <jh.leong@outlook.com>
Tue, 13 Aug 2024 14:06:10 +0000 (22:06 +0800)
committerEvan You <evan@vuejs.org>
Thu, 15 Aug 2024 07:31:14 +0000 (15:31 +0800)
packages/runtime-dom/src/index.ts

index 44ada3d935f4ae7bbf0bf007e884fb833fb6697c..6b110d00a78f58bef2ce33a8b026308d6489df85 100644 (file)
@@ -26,9 +26,17 @@ import {
   isString,
 } from '@vue/shared'
 
+/**
+ * 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<T> = typeof globalThis extends { window: unknown } ? T : DomStub
+
 declare module '@vue/reactivity' {
   export interface RefUnwrapBailTypes {
-    runtimeDOMBailTypes: Node | Window
+    runtimeDOMBailTypes: DomType<Node | Window>
   }
 }