Browse Source

fix(props): support BigInt in props type validation (#11191)

dev
AjiTae 4 years ago
committed by GitHub
parent
commit
fa1f81e910
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/core/util/props.js
  2. 10
      test/unit/features/options/props.spec.js

2
src/core/util/props.js

@ -147,7 +147,7 @@ function assertProp (
}
}
const simpleCheckRE = /^(String|Number|Boolean|Function|Symbol)$/
const simpleCheckRE = /^(String|Number|Boolean|Function|Symbol|BigInt)$/
function assertType (value: any, type: Function, vm: ?Component): {
valid: boolean;

10
test/unit/features/options/props.spec.js

@ -252,6 +252,16 @@ describe('Options props', () => {
expect('Expected String, Number, got Symbol').toHaveBeenWarned()
})
}
if (typeof BigInt !== 'undefined') {
/* global BigInt */
it('bigint', () => {
makeInstance(BigInt(100), BigInt)
expect(console.error.calls.count()).toBe(0)
makeInstance({}, BigInt)
expect('Expected BigInt, got Object').toHaveBeenWarned()
})
}
it('custom constructor', () => {
function Class () {}

Loading…
Cancel
Save