Skip to content

Commit ffd5288

Browse files
authored
feat(runtime-core): props type support BigInt (#2891)
1 parent de7f9d1 commit ffd5288

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

packages/runtime-core/__tests__/componentProps.spec.ts

+21
Original file line numberDiff line numberDiff line change
@@ -378,4 +378,25 @@ describe('component props', () => {
378378
expect(setupProps).toMatchObject(props)
379379
expect(renderProxy.$props).toMatchObject(props)
380380
})
381+
382+
test('props type support BigInt', () => {
383+
const Comp = {
384+
props: {
385+
foo: BigInt
386+
},
387+
render(this: any) {
388+
return h('div', [this.foo])
389+
}
390+
}
391+
392+
const root = nodeOps.createElement('div')
393+
render(
394+
h(Comp, {
395+
foo: BigInt(BigInt(100000111)) + BigInt(2000000000) * BigInt(30000000)
396+
}),
397+
root
398+
)
399+
400+
expect(serializeInner(root)).toMatch('<div>60000000100000111</div>')
401+
})
381402
})

packages/runtime-core/src/componentProps.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ function validateProp(
510510
}
511511

512512
const isSimpleType = /*#__PURE__*/ makeMap(
513-
'String,Number,Boolean,Function,Symbol'
513+
'String,Number,Boolean,Function,Symbol,BigInt'
514514
)
515515

516516
type AssertionResult = {

0 commit comments

Comments
 (0)