Skip to content

vue/require-valid-default-prop error with TypeScript #2692

Closed
@mrleblanc101

Description

@mrleblanc101

Checklist

  • I have tried restarting my IDE and the issue persists.
  • I have read the FAQ and my problem is not listed.

Tell us about your environment

  • ESLint version: 9.20.1
  • eslint-plugin-vue version: 9.32.0
  • Vue version: 3.5.13
  • Node version: v20.18.0
  • Operating System: macOS 15.3.1

Please show your full configuration:

import eslintConfigPrettier from 'eslint-config-prettier';
import prettierPlugin from 'eslint-plugin-prettier';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';

import withNuxt from './.playground/.nuxt/eslint.config.mjs';

export default withNuxt({
    plugins: {
        prettier: prettierPlugin,
    },
    rules: {
        ...prettierPlugin.configs.recommended.rules,
        ...eslintConfigPrettier.rules,
        ...eslintPluginPrettierRecommended.rules,
        'vue/no-bare-strings-in-template': [
            'error',
            {
                attributes: {
                    '/.+/': [
                        'title',
                        'description',
                        'label',
                        'help',
                        'tooltip',
                        'placeholder',
                        'errors',
                        'content',
                        'confirmButtonLabel',
                        'cancelButtonLabel',
                    ],
                    'UTab': ['name'],
                },
                directives: ['v-text'],
            },
        ],
        'vue/v-slot-style': ['error', 'shorthand'],
    },
}).append({
    files: ['.playground/**/*.vue'],
    rules: {
        'vue/no-bare-strings-in-template': 'off',
    },
});

What did you do?

<script lang="ts" setup>
type MaybeString<T extends number> = T | `${T}`;

const { level = 1 } = defineProps<{
    title: string;
    tooltip?: string;
    level?: MaybeString<1 | 2 | 3 | 4 | 5 | 6>;
}>();
</script>

What did you expect to happen?
No error

What actually happened?

Type of the default value for 'level' prop must be a string. eslintvue/require-valid-default-prop

Repository to reproduce this issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions