@@ -122,13 +122,14 @@ function assertProp (
122
122
type = [ type ]
123
123
}
124
124
for ( let i = 0 ; i < type . length && ! valid ; i ++ ) {
125
- const assertedType = assertType ( value , type [ i ] )
125
+ const assertedType = assertType ( value , type [ i ] , vm )
126
126
expectedTypes . push ( assertedType . expectedType || '' )
127
127
valid = assertedType . valid
128
128
}
129
129
}
130
130
131
- if ( ! valid ) {
131
+ const haveExpectedTypes = expectedTypes . some ( t => t )
132
+ if ( ! valid && haveExpectedTypes ) {
132
133
warn (
133
134
getInvalidTypeMessage ( name , value , expectedTypes ) ,
134
135
vm
@@ -148,7 +149,7 @@ function assertProp (
148
149
149
150
const simpleCheckRE = / ^ ( S t r i n g | N u m b e r | B o o l e a n | F u n c t i o n | S y m b o l ) $ /
150
151
151
- function assertType ( value : any , type : Function ) : {
152
+ function assertType ( value : any , type : Function , vm : ? Component ) : {
152
153
valid: boolean ;
153
154
expectedType: string ;
154
155
} {
@@ -166,7 +167,12 @@ function assertType (value: any, type: Function): {
166
167
} else if ( expectedType === 'Array' ) {
167
168
valid = Array . isArray ( value )
168
169
} else {
169
- valid = value instanceof type
170
+ try {
171
+ valid = value instanceof type
172
+ } catch ( e ) {
173
+ warn ( 'Invalid prop type: "' + String ( type ) + '" is not a constructor' , vm ) ;
174
+ valid = false ;
175
+ }
170
176
}
171
177
return {
172
178
valid,
0 commit comments