Skip to content

Commit 4db0085

Browse files
jh-leongyyx990803
authored andcommitted
fix(types): add fallback stub for DOM types when DOM lib is absent (#11598)
1 parent 28db2e6 commit 4db0085

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

packages/runtime-dom/src/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,17 @@ import {
2626
isString,
2727
} from '@vue/shared'
2828

29+
/**
30+
* This is a stub implementation to prevent the need to use dom types.
31+
*
32+
* To enable proper types, add `"dom"` to `"lib"` in your `tsconfig.json`.
33+
*/
34+
type DomStub = {}
35+
type DomType<T> = typeof globalThis extends { window: unknown } ? T : DomStub
36+
2937
declare module '@vue/reactivity' {
3038
export interface RefUnwrapBailTypes {
31-
runtimeDOMBailTypes: Node | Window
39+
runtimeDOMBailTypes: DomType<Node | Window>
3240
}
3341
}
3442

0 commit comments

Comments
 (0)