When props use generics and are simultaneously used with withDefaults, toRefs cannot correctly infer their types
Open
Nobody has claimed this yet.
scope: types
- Dominant language
- TypeScript
- Stars
- 54.4k
- Forks
- 9.2k
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 140
Description
Vue version
3.3.10
Link to minimal reproduction
Steps to reproduce
- Define a prop using generics, and then specify another prop using a non-generic definition.
- Use
toRefsto resolve the props - Use resolved prop attach to nested component
What is expected?
The type is correct.
What is actually happening?
The type is incorrect.
System Info
System:
OS: macOS 14.1.2
CPU: (10) x64 Apple M2 Pro
Memory: 303.87 MB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 18.16.0 - ~/.nvm/versions/node/v18.16.0/bin/node
Yarn: 1.22.21 - ~/Library/pnpm/yarn
npm: 9.5.1 - ~/.nvm/versions/node/v18.16.0/bin/npm
pnpm: 8.11.0 - ~/Library/pnpm/pnpm
Browsers:
Chrome: 120.0.6099.62
Safari: 17.1.2
npmPackages:
vue: ^3.3.10 => 3.3.10
Any additional comments?
No response
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 Vue Play reproduction and inspect the TypeScript typings involved in generic props, withDefaults, and toRefs. Compare the inferred type with the expected nested-component prop type; done means the resolved prop type is inferred correctly without changing the reproduction setup.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100