props: {
bool: { type: Boolean },
str: { type: String },
+ symStr: { type: String },
+ sym: { type: Symbol },
num: { type: Number },
arr: { type: Array },
obj: { type: Object },
h(Comp, {
bool: 'true',
str: 100,
+ symStr: Symbol(),
+ sym: 'symbol',
num: '100',
arr: {},
obj: 'false',
expect(
`Invalid prop: type check failed for prop "str". Expected String with value "100", got Number with value 100.`,
).toHaveBeenWarned()
+ expect(
+ `Invalid prop: type check failed for prop "symStr". Expected String, got Symbol`,
+ ).toHaveBeenWarned()
+ expect(
+ `Invalid prop: type check failed for prop "sym". Expected Symbol, got String with value "symbol".`,
+ ).toHaveBeenWarned()
expect(
`Invalid prop: type check failed for prop "num". Expected Number with value 100, got String with value "100".`,
).toHaveBeenWarned()
isOn,
isReservedProp,
isString,
+ isSymbol,
makeMap,
toRawType,
} from '@vue/shared'
if (
expectedTypes.length === 1 &&
isExplicable(expectedType) &&
- !isBoolean(expectedType, receivedType)
+ isCoercible(expectedType, receivedType)
) {
message += ` with value ${expectedValue}`
}
* dev only
*/
function styleValue(value: unknown, type: string): string {
- if (type === 'String') {
+ if (isSymbol(value)) {
+ return value.toString()
+ } else if (type === 'String') {
return `"${value}"`
} else if (type === 'Number') {
return `${Number(value)}`
/**
* dev only
*/
-function isBoolean(...args: string[]): boolean {
- return args.some(elem => elem.toLowerCase() === 'boolean')
+function isCoercible(...args: string[]): boolean {
+ return args.every(elem => {
+ const value = elem.toLowerCase()
+ return value !== 'boolean' && value !== 'symbol'
+ })
}