File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
test/unit/features/options Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -145,7 +145,12 @@ function assertType (value: any, type: Function): {
145145 let valid
146146 const expectedType = getType ( type )
147147 if ( simpleCheckRE . test ( expectedType ) ) {
148- valid = typeof value === expectedType . toLowerCase ( )
148+ const t = typeof value
149+ valid = t === expectedType . toLowerCase ( )
150+ // for primitive wrapper objects
151+ if ( ! valid && t === 'object' ) {
152+ valid = value instanceof type
153+ }
149154 } else if ( expectedType === 'Object' ) {
150155 valid = isPlainObject ( value )
151156 } else if ( expectedType === 'Array' ) {
Original file line number Diff line number Diff line change @@ -206,6 +206,17 @@ describe('Options props', () => {
206206 expect ( 'Expected Array' ) . toHaveBeenWarned ( )
207207 } )
208208
209+ it ( 'primitive wrapper objects' , ( ) => {
210+ /* eslint-disable no-new-wrappers */
211+ makeInstance ( new String ( 's' ) , String )
212+ expect ( console . error . calls . count ( ) ) . toBe ( 0 )
213+ makeInstance ( new Number ( 1 ) , Number )
214+ expect ( console . error . calls . count ( ) ) . toBe ( 0 )
215+ makeInstance ( new Boolean ( true ) , Boolean )
216+ expect ( console . error . calls . count ( ) ) . toBe ( 0 )
217+ /* eslint-enable no-new-wrappers */
218+ } )
219+
209220 if ( hasSymbol ) {
210221 it ( 'symbol' , ( ) => {
211222 makeInstance ( Symbol ( 'foo' ) , Symbol )
You can’t perform that action at this time.
0 commit comments