Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript possible undefined loses type when using withDefaults and setting explicitly to undefined #1672

Closed
VividLemon opened this issue Aug 4, 2022 · 1 comment
Labels

Comments

@VividLemon
Copy link

If you do

interface Props { id?: number }

const props = withDefaults(defineProps<Props>(), { id: undefined })

if you observer props.id, even though the default is undefined, it will lose it's type and it will always claim to be number.

image

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants