obj: { type: Object },
cls: { type: MyClass },
fn: { type: Function },
- skipCheck: { type: [Boolean, Function], skipCheck: true }
+ skipCheck: { type: [Boolean, Function], skipCheck: true },
+ empty: { type: [] }
},
setup() {
return () => null
obj: 'false',
cls: {},
fn: true,
- skipCheck: 'foo'
+ skipCheck: 'foo',
+ empty: [1, 2, 3]
}),
nodeOps.createElement('div')
)
expect(
`Invalid prop: type check failed for prop "skipCheck". Expected Boolean | Function, got String with value "foo".`
).not.toHaveBeenWarned()
+ expect(
+ `Prop type [] for prop "empty" won't match anything. Did you mean to use type Array instead?`
+ ).toHaveBeenWarned()
})
// #3495
value: unknown,
expectedTypes: string[]
): string {
+ if (expectedTypes.length === 0) {
+ return (
+ `Prop type [] for prop "${name}" won't match anything.` +
+ ` Did you mean to use type Array instead?`
+ )
+ }
let message =
`Invalid prop: type check failed for prop "${name}".` +
` Expected ${expectedTypes.map(capitalize).join(' | ')}`