Bug: Optional props are typed as `| undefined`
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.2k
- Forks
- 291
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 18
Description
Describe the bug
When using the .props() method on a VueWrapper for a prop which is not required but has a default value the returned type includes undefined.
To Reproduce
https://github.com/DesselBane/test-utils-reproduction/blob/master/src/components/foo.spec.ts
Expected behavior
I would argue that the type should not include undefined since it has a default value and this default value is returned at runtime.
Related information:
This happened on an update from v2.4.1 to v2.4.2, most likely somewhere in this PR: https://github.com/vuejs/test-utils/pull/2137 (but I'm not sure)
Contributor guide
No contributing guide indexed for this repository
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 in src/components/foo.spec.ts and compare the behavior between versions 2.4.1 and 2.4.2. Review PR 2137 and the surrounding prop type definitions; done means VueWrapper.props() no longer includes undefined for optional props with runtime defaults, while preserving correct typing for other props.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend, testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100