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
vue/require-default-prop
gives false positive for optional Function props
#2376
Comments
Not sure... there are similarities to the last comment on #2051, but otherwise this looks different. I'm looking at it more deeply, and it appears the problem is the use of spreading in my defaults. My actual defaults look like this: const props = withDefaults(<
ICommonProps && {
onToggle?: ToggleCallback
}>(),
{
...CommonPropDefaults,
onToggle: (_: Item) => {},
} CommonPropDefaults just has defaults for other properties that are common across several components -- nothing related to the Function prop. But without the spread operator in the second argument of So... I guess I'm going to need to create a reproduction. |
Checklist
Tell us about your environment
Please show your full configuration:
What did you do?
-- MyComponent.vue export type ToggleCallback = (target: Item) => void const props = withDefaults( defineProps<{ item: Item onToggle?: ToggleCallback }>(), { onToggle: (_: Item) => {}, } )
What did you expect to happen?
I've provided a default for this Function-typed property, so I don't expect an error. I also wouldn't expect an error if I set the default to
undefined
ornull
.What actually happened?
Repository to reproduce this issue
No time right now to reproduce. Might be easier if I write a test for your test package, but not sure if you accept PRs for that?
The text was updated successfully, but these errors were encountered: