@@ -205,18 +205,19 @@ function getInvalidTypeMessage (name, value, expectedTypes) {
205
205
` Expected ${ expectedTypes . map ( capitalize ) . join ( ', ' ) } `
206
206
const expectedType = expectedTypes [ 0 ]
207
207
const receivedType = toRawType ( value )
208
- const expectedValue = styleValue ( value , expectedType )
209
- const receivedValue = styleValue ( value , receivedType )
210
208
// check if we need to specify expected value
211
- if ( expectedTypes . length === 1 &&
212
- isExplicable ( expectedType ) &&
213
- ! isBoolean ( expectedType , receivedType ) ) {
214
- message += ` with value ${ expectedValue } `
209
+ if (
210
+ expectedTypes . length === 1 &&
211
+ isExplicable ( expectedType ) &&
212
+ isExplicable ( typeof value ) &&
213
+ ! isBoolean ( expectedType , receivedType )
214
+ ) {
215
+ message += ` with value ${ styleValue ( value , expectedType ) } `
215
216
}
216
217
message += `, got ${ receivedType } `
217
218
// check if we need to specify received value
218
219
if ( isExplicable ( receivedType ) ) {
219
- message += `with value ${ receivedValue } .`
220
+ message += `with value ${ styleValue ( value , receivedType ) } .`
220
221
}
221
222
return message
222
223
}
@@ -231,9 +232,9 @@ function styleValue (value, type) {
231
232
}
232
233
}
233
234
234
- function isExplicable ( value ) {
235
- const explicitTypes = [ 'string' , 'number' , 'boolean' ]
236
- return explicitTypes . some ( elem => value . toLowerCase ( ) === elem )
235
+ const EXPLICABLE_TYPES = [ 'string' , 'number' , 'boolean' ]
236
+ function isExplicable ( value ) {
237
+ return EXPLICABLE_TYPES . some ( elem => value . toLowerCase ( ) === elem )
237
238
}
238
239
239
240
function isBoolean ( ...args ) {
0 commit comments