Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

vue/require-valid-default-prop breaks when importing type with union #2279

Open
@VividLemon

Description

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: 8.45.0
  • eslint-plugin-vue version: 9.15.1
  • Node version: v20.3.1
  • Operating System: Linux

Please show your full configuration:

/* eslint-env node */
require('@rushstack/eslint-patch/modern-module-resolution')
const {defineConfig} = require('eslint-define-config')
module.exports = defineConfig({
 root: true,
 'extends': [
 'plugin:vue/vue3-essential',
 'eslint:recommended',
 '@vue/eslint-config-typescript',
 '@vue/eslint-config-prettier/skip-formatting'
 ],
 parserOptions: {
 ecmaVersion: 'latest'
 },
 rules: {
 'vue/require-valid-default-prop': 'error'
 }
})

What did you do?

<script setup lang="ts">
import type { Foo } from '../types';

// type Foo = boolean

const props = withDefaults(defineProps<{
 msg?: Foo | 'foo'
}>(), {
 msg: false, // Errors here `Type of the default value for 'msg' prop must be a string.`
})
</script>
<template>
 <div class="greetings">
 </div>
</template>
export type Foo = boolean

What did you expect to happen?

No error, this is valid syntax post Vue 3.3

What actually happened?

Type of the default value for 'msg' prop must be a string.

This is incorrect, as this is correct post Vue 3.3.

Repository to reproduce this issue

https://github.com/VividLemon/vue-eslint-require-default-prop-bug

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

        AltStyle によって変換されたページ (->オリジナル) /