// range is offset by -1 due to the wrapping parens when parsed
const start = id.start - 1
const end = id.end - 1
- const last = ids[i - 1] as any
+ const last = ids[i - 1]
const leadingText = rawExp.slice(last ? last.end - 1 : 0, start)
if (leadingText.length || id.prefix) {
children.push(leadingText + (id.prefix || ``))
`It will be overwritten with the new value.`
)
}
- context.provides[key as any] = value
+ // TypeScript doesn't allow symbols as index type
+ // https://github.com/Microsoft/TypeScript/issues/24587
+ context.provides[key as string] = value
}
}
if (parentProvides === provides) {
provides = currentInstance.provides = Object.create(parentProvides)
}
- provides[key as any] = value
+ // TS doesn't allow symbol as index type
+ provides[key as string] = value
}
}
if (currentInstance) {
const provides = currentInstance.provides
if (key in provides) {
- return provides[key as any] as any
+ // TS doesn't allow symbol as index type
+ return provides[key as string]
} else if (defaultValue !== undefined) {
return defaultValue
} else if (__DEV__) {
instance.renderContext === EMPTY_OBJ
? (instance.renderContext = reactive({}))
: instance.renderContext
- const ctx = instance.renderProxy as any
+ const ctx = instance.renderProxy!
const {
// composition
mixins,
if (isString(raw)) {
const handler = renderContext[raw]
if (isFunction(handler)) {
- watch(getter, handler as any)
+ watch(getter, handler as WatchHandler)
} else if (__DEV__) {
// TODO warn invalid watch handler path
}
cb: Function,
options?: WatchOptions
): () => void {
- const ctx = this.renderProxy as any
+ const ctx = this.renderProxy!
const getter = isString(source) ? () => ctx[source] : source.bind(ctx)
const stop = watch(getter, cb.bind(ctx), options)
onBeforeUnmount(stop, this)
type: vnode.type as Component,
root: null as any, // set later so it can point to itself
next: null,
- subTree: null as any,
- update: null as any,
+ subTree: null as any, // will be set synchronously right after creation
+ update: null as any, // will be set synchronously right after creation
render: null,
renderProxy: null,
propsProxy: null,
M = {},
PublicProps = P
> = {
+ [key: string]: any
$data: D
$props: PublicProps
$attrs: Data
slots,
emit
})
- : render(props, null as any)
+ : render(props, null as any /* we know it doesn't it */)
)
}
} catch (err) {
import { warn } from './warning'
export type Slot = (...args: any[]) => VNodeChildren
-export type Slots = Readonly<{
+
+export type InternalSlots = {
[name: string]: Slot
-}>
+}
+
+export type Slots = Readonly<InternalSlots>
+
export type RawSlots = {
[name: string]: unknown
+ _compiled?: boolean
}
const normalizeSlotValue = (value: unknown): VNode[] =>
instance: ComponentInternalInstance,
children: NormalizedChildren
) {
- let slots: Slots | void
+ let slots: InternalSlots | void
if (instance.vnode.shapeFlag & ShapeFlags.SLOTS_CHILDREN) {
- if ((children as any)._compiled) {
+ const rawSlots = children as RawSlots
+ if (rawSlots._compiled) {
// pre-normalized slots object generated by compiler
slots = children as Slots
} else {
slots = {}
- for (const key in children as RawSlots) {
- let value = (children as RawSlots)[key]
+ for (const key in rawSlots) {
+ const value = rawSlots[key]
if (isFunction(value)) {
- ;(slots as any)[key] = normalizeSlot(key, value)
+ slots[key] = normalizeSlot(key, value)
} else if (value != null) {
if (__DEV__) {
warn(
`Prefer function slots for better performance.`
)
}
- value = normalizeSlotValue(value)
- ;(slots as any)[key] = () => value
+ const normalized = normalizeSlotValue(value)
+ slots[key] = () => normalized
}
}
}
nextVNode.component = instance
instance.vnode = nextVNode
instance.next = null
- resolveProps(instance, nextVNode.props, (nextVNode.type as any).props)
+ resolveProps(instance, nextVNode.props, (nextVNode.type as Component).props)
resolveSlots(instance, nextVNode.children)
}
vnode = cloneVNode(vnode)
vnode.props = vnode.props != null ? extend({}, vnode.props) : {}
for (let i = 0; i < directives.length; i++) {
- ;(applyDirective as any)(vnode.props, instance, ...directives[i])
+ const [dir, value, arg, modifiers] = directives[i]
+ applyDirective(vnode.props, instance, dir, value, arg, modifiers)
}
} else if (__DEV__) {
warn(`applyDirectives can only be used inside render functions.`)
-import { VNode, normalizeVNode } from './vnode'
+import { VNode, normalizeVNode, VNodeChild } from './vnode'
import { ShapeFlags } from '.'
import { isFunction } from '@vue/shared'
import { ComponentInternalInstance } from './component'
+import { Slots } from './componentSlots'
export const SuspenseSymbol = __DEV__ ? Symbol('Suspense key') : Symbol()
} {
const { shapeFlag, children } = vnode
if (shapeFlag & ShapeFlags.SLOTS_CHILDREN) {
- const { default: d, fallback } = children as any
+ const { default: d, fallback } = children as Slots
return {
content: normalizeVNode(isFunction(d) ? d() : d),
fallback: normalizeVNode(isFunction(fallback) ? fallback() : fallback)
}
} else {
return {
- content: normalizeVNode(children as any),
+ content: normalizeVNode(children as VNodeChild),
fallback: normalizeVNode(null)
}
}
} from '@vue/runtime-core'
import { ErrorCodes } from 'packages/runtime-core/src/errorHandling'
-interface Invoker extends Function {
+interface Invoker extends EventListener {
value: EventValue
- lastUpdated?: number
+ lastUpdated: number
}
type EventValue = (Function | Function[]) & {
el.addEventListener(name, createInvoker(nextValue, instance))
}
} else if (invoker) {
- el.removeEventListener(name, invoker as any)
+ el.removeEventListener(name, invoker)
}
}
initialValue: any,
instance: ComponentInternalInstance | null
) {
- const invoker = ((e: Event) => {
+ const invoker: Invoker = (e: Event) => {
// async edge case #6566: inner click event triggers patch, event handler
// attached to outer element during patch, and triggered again. This
// happens because browsers fire microtask ticks between event propagation.
)
}
}
- }) as any
+ }
invoker.value = initialValue
initialValue.invoker = invoker
invoker.lastUpdated = getNow()