]> 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)
committerGitHub <noreply@github.com>
Tue, 13 Aug 2024 14:06:10 +0000 (22:06 +0800)
packages/runtime-dom/src/index.ts

index 344cbf37584e919664880a574a6009c5fc5f06f0..64bfacef22fa5011625deb08769c5926bb88f103 100644 (file)
@@ -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<T> = typeof globalThis extends { window: unknown } ? T : DomStub
+
 declare module '@vue/reactivity' {
   export interface RefUnwrapBailTypes {
-    runtimeDOMBailTypes: Node | Window
+    runtimeDOMBailTypes: DomType<Node | Window>
   }
 }