When using TypeScript, BigInt is not usable as a component prop type.
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 54.4k
- Forks
- 9.2k
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 140
Description
Version
3.2.31
Reproduction link
Steps to reproduce
Create a project with npm init vue@latest, configure it to use TypeScript, set the tsconfig and vite config to target ES2020, and then add a prop to one of the components whose type is BigInt (see TheWelcome.vue in the reproduction link). The ES2020 configuration is required for BigInt to be recognized in the first place.
Run either npm run build or npm run typecheck to see the errors.
What is expected?
Setting a prop's type to BigInt should just work (tm)
What is actually happening?
Type errors, and compilation failures. Notably the prop definition line shows the following error:
error TS2769: No overload matches this call.
The last overload gave the following error.
Type 'BigIntConstructor' is not assignable to type 'Prop<unknown, unknown> | null'.
Type 'BigIntConstructor' is not assignable to type '() => unknown'.
This issue exists despite the announcement here and the closed issue here.
A workaround is to define a wrapper class and use propname: Object as PropType<MyWrappe>. Then wrap the bigint in a method when passing it in as a prop, and access the inner class field when reading the prop.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked reproduction, especially TheWelcome.vue, and run npm run build or npm run typecheck after configuring TypeScript and Vite for ES2020. Trace the reported BigIntConstructor prop-type error. Done means a BigInt component prop is accepted without type errors or compilation failures.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100