1
<script setup lang="ts">
import { computed } from 'vue';

type Props = {
  duration?: '0'|'0.5'|'1'|'1.5'|'2'|'2.5'|'3'|'4'|'5'|'6'|'7'|'8'|'9'|'10',
//^^^^^^^^^ ESLint: Prop 'duration' requires default value to be set.(vue/require-default-prop)
  initialAnimation?: boolean,
  additionalAnimateClasses?: string
};

const props = withDefaults(defineProps<Props>(), {
//                         ^^^^^^^^^^^^^^^^^^^^ Argument type DefineProps<Props, BooleanKey<Props>> is not assignable to parameter type DefineProps<Readonly<Props> & {readonly initialAnimation: boolean}, keyof Readonly<Props> & {readonly initialAnimation: boolean}> 
  initialAnimation: true,
  additionalAnimateClasses: ''
});

Why this erros are showing? My intension is to set default value for some of the optional props

2
  • I think ESLint is wrong here. You can always disable the rule for the specific line, or provide duration: undefined fo the default value within the withDefaults macro to make ESLint happy Commented Jun 1, 2023 at 16:51
  • Thank you @yoduh, I can disable it but wanted a solution so EsLint doesn't complains & the 2nd error from TS Commented Jun 2, 2023 at 12:15

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.