Skip to content

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

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

Closed
2 tasks done
mrleblanc101 opened this issue Feb 28, 2025 · 0 comments · Fixed by #2693
Closed
2 tasks done

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

mrleblanc101 opened this issue Feb 28, 2025 · 0 comments · Fixed by #2693
Labels

Comments

@mrleblanc101
Copy link

mrleblanc101 commented Feb 28, 2025

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

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

Successfully merging a pull request may close this issue.

2 participants