Skip to content

Commit fee6697

Browse files
authored
fix(types): add fallback stub for DOM types when DOM lib is absent (#11598)
1 parent 73fa91f commit fee6697

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Diff for: packages/runtime-dom/src/index.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,17 @@ import type { vShow } from './directives/vShow'
3333
import type { VOnDirective } from './directives/vOn'
3434
import type { VModelDirective } from './directives/vModel'
3535

36+
/**
37+
* This is a stub implementation to prevent the need to use dom types.
38+
*
39+
* To enable proper types, add `"dom"` to `"lib"` in your `tsconfig.json`.
40+
*/
41+
type DomStub = {}
42+
type DomType<T> = typeof globalThis extends { window: unknown } ? T : DomStub
43+
3644
declare module '@vue/reactivity' {
3745
export interface RefUnwrapBailTypes {
38-
runtimeDOMBailTypes: Node | Window
46+
runtimeDOMBailTypes: DomType<Node | Window>
3947
}
4048
}
4149

0 commit comments

Comments
 (0)