types: use stricter HostNode typings

This commit is contained in:
Evan You
2019-09-06 16:58:32 -04:00
parent 360f3b4f37
commit 3904678306
12 changed files with 228 additions and 171 deletions

View File

@@ -1,14 +1,18 @@
import { createRenderer, VNode, createAppAPI } from '@vue/runtime-core'
import { createRenderer } from '@vue/runtime-core'
import { nodeOps } from './nodeOps'
import { patchProp } from './patchProp'
export const render = createRenderer({
const { render, createApp } = createRenderer<Node, Element>({
patchProp,
...nodeOps
}) as (vnode: VNode | null, container: HTMLElement) => void
})
export const createApp = createAppAPI(render)
export { render, createApp }
// re-export everything from core
// h, Component, reactivity API, nextTick, flags & types
export * from '@vue/runtime-core'
export interface ComponentPublicInstance {
$el: Element
}

View File

@@ -45,7 +45,7 @@ export function patchEvent(
name: string,
prevValue: EventValue | null,
nextValue: EventValue | null,
instance: ComponentInternalInstance | null
instance: ComponentInternalInstance | null = null
) {
const invoker = prevValue && prevValue.invoker
if (nextValue) {

View File

@@ -36,5 +36,6 @@ export const nodeOps = {
nextSibling: (node: Node): Node | null => node.nextSibling,
querySelector: (selector: string): Node | null => doc.querySelector(selector)
querySelector: (selector: string): Element | null =>
doc.querySelector(selector)
}

View File

@@ -4,7 +4,7 @@ import { patchAttr } from './modules/attrs'
import { patchDOMProp } from './modules/props'
import { patchEvent } from './modules/events'
import { isOn } from '@vue/shared'
import { VNode } from '@vue/runtime-core'
import { VNode, ComponentInternalInstance } from '@vue/runtime-core'
export function patchProp(
el: Element,
@@ -13,7 +13,7 @@ export function patchProp(
prevValue: any,
isSVG: boolean,
prevChildren?: VNode[],
parentComponent?: any,
parentComponent?: ComponentInternalInstance,
unmountChildren?: any
) {
switch (key) {