fix(types): add fallback stub for DOM types when DOM lib is absent (#11598)

This commit is contained in:
Tycho 2024-08-13 22:06:10 +08:00 committed by GitHub
parent 73fa91fabd
commit fee669764f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 1 deletions

View 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>
}
}