PropType
} from './componentOptions'
import { EMPTY_OBJ, camelize, hyphenate, capitalize } from './utils'
+import { warn } from './warning'
const EMPTY_PROPS = { props: EMPTY_OBJ }
if (Array.isArray(raw)) {
for (let i = 0; i < raw.length; i++) {
if (__DEV__ && typeof raw !== 'string') {
- console.warn(`props must be strings when using array syntax.`)
+ warn(`props must be strings when using array syntax.`)
}
normalized[camelize(raw[i])] = EMPTY_OBJ
}
} else {
if (__DEV__ && typeof raw !== 'object') {
- console.warn(`invalid props options: `, raw)
+ warn(`invalid props options`, raw)
}
for (const key in raw) {
const opt = raw[key]
const { type, required, validator } = prop
// required!
if (required && isAbsent) {
- console.warn('Missing required prop: "' + name + '"')
+ warn('Missing required prop: "' + name + '"')
return
}
// missing but optional
isValid = valid
}
if (!isValid) {
- console.warn(getInvalidTypeMessage(name, value, expectedTypes))
+ warn(getInvalidTypeMessage(name, value, expectedTypes))
return
}
}
// custom validator
if (validator && !validator(value)) {
- console.warn(
- 'Invalid prop: custom validator check failed for prop "' + name + '".'
- )
+ warn('Invalid prop: custom validator check failed for prop "' + name + '".')
}
}
import { ComponentOptions } from './componentOptions'
import { createRenderProxy } from './componentProxy'
import { handleError, ErrorTypes } from './errorHandling'
+import { warn } from './warning'
let currentVNode: VNode | null = null
let currentContextVNode: MountedVNode | null = null
} else if (key === 'methods') {
for (const method in value) {
if (__DEV__ && proto.hasOwnProperty(method)) {
- console.warn(
+ warn(
`Object syntax contains method name that conflicts with ` +
`lifecycle hook: "${method}"`
)
import { autorun, stop } from '@vue/observer'
import { queueJob } from '@vue/scheduler'
import { handleError, ErrorTypes } from './errorHandling'
+import { warn } from './warning'
export function initializeWatch(
instance: ComponentInstance,
: () => keyOrFn.call(proxy)
if (__DEV__ && rawGetter === NOOP) {
- console.warn(
+ warn(
`Failed watching expression: "${keyOrFn}". ` +
`Watch expressions can only be dot-delimited paths. ` +
`For more complex expressions, use $watch with a function instead.`
createPortal
} from './vdom'
import { isObservable } from '@vue/observer'
+import { warn } from './warning'
export const Fragment = Symbol()
export const Portal = Symbol()
)
} else if (tag === Fragment) {
if (__DEV__ && ref) {
- console.warn(
- 'Ref cannot be used on Fragments. Use it on inner elements instead.'
- )
+ warn('Ref cannot be used on Fragments. Use it on inner elements instead.')
}
return createFragment(children, ChildrenFlags.UNKNOWN_CHILDREN, key)
} else if (tag === Portal) {
if (__DEV__ && !portalTarget) {
- console.warn('Portal must have a target: ', portalTarget)
+ warn('Portal must have a target: ', portalTarget)
}
return createPortal(
portalTarget,
__DEV__ &&
(!tag || (typeof tag !== 'function' && typeof tag !== 'object'))
) {
- console.warn('Invalid component passed to h(): ', tag)
+ warn('Invalid component passed to h(): ', tag)
}
// component
return createComponentVNode(
import { observable } from '@vue/observer'
import { Component } from '../component'
+import { warn } from '../warning'
const contextStore = observable() as Record<string | symbol, any>
if (__DEV__) {
const { id } = this.$props
if (contextStore.hasOwnProperty(id)) {
- console.warn(
- `A context provider with id ${id.toString()} already exists.`
- )
+ warn(`A context provider with id ${id.toString()} already exists.`)
}
this.$watch(
() => this.$props.id,
(id: string, oldId: string) => {
- console.warn(
+ warn(
`Context provider id change detected (from "${oldId}" to "${id}"). ` +
`This is not supported and should be avoided.`
)
import { Component, ComponentClass, ComponentInstance } from '../component'
import { VNode, Slots, cloneVNode } from '../vdom'
import { VNodeFlags } from '../flags'
+import { warn } from '../warning'
type MatchPattern = string | RegExp | string[] | RegExp[]
let vnode = children[0]
if (children.length > 1) {
if (__DEV__) {
- console.warn(`KeepAlive can only have a single child.`)
+ warn(`KeepAlive can only have a single child.`)
}
return children
} else if ((vnode.flags & VNodeFlags.COMPONENT_STATEFUL) === 0) {
if (__DEV__) {
- console.warn(`KeepAlive child must be a stateful component.`)
+ warn(`KeepAlive child must be a stateful component.`)
}
return children
}
stack.pop()
}
-export function warn(msg: string) {
+export function warn(msg: string, ...args: any[]) {
// TODO warn handler?
- console.warn(`[Vue warn]: ${msg}${getComponentTrace()}`)
+ warn(`[Vue warn]: ${msg}${getComponentTrace()}`, ...args)
}
function getComponentTrace(): string {
let current: VNode | null | undefined = stack[stack.length - 1]
if (!current) {
- return '\nat <Root/>'
+ return ''
}
// we can't just use the stack because it will be incomplete during updates