Skip to content

Commit

Permalink
fix(types): add fallback stub for DOM types when DOM lib is absent (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jh-leong committed Aug 13, 2024
1 parent 73fa91f commit fee6697
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/runtime-dom/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>
}
}

Expand Down

0 comments on commit fee6697

Please # to comment.