Skip to content

vue/require-default-prop should not trigger when type is x | undefined without default value #2475

Open
@Aspyryan

Description

@Aspyryan

What rule do you want to change?
vue/require-default-prop

Does this change cause the rule to produce more or fewer warnings?
Is will provide less warnings if the type is already defined as undefined.

How will the change be implemented? (New option, new default behavior, etc.)?
Could be an option to not throw the error / warning when props is not required and has a undefined type set

Please provide some example code that this change will affect:

const props = withDefaults(
  defineProps<{
    // Is not throwing warning because default is set
    modelValue?: string;
    // Should throw warning because no default is set
    label?: string;
    // Should not throw warning because undefined is allowed
    propertyName?: string | undefined;
  }>(),
  {
    modelValue: 'test',
  },
);

What does the rule currently do for this code?
Throws a warning at the propertyName prop

What will the rule do after it's changed?
Will not complain about the propertyName prop

Additional context
If needed, I can look into it myself but I will need to be pointed to the correct files :)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions