Skip to content

False negative with vue/require-valid-default-prop on props with type assertion #1468

Closed
@frozenbonito

Description

@frozenbonito

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: 7.23.0
  • eslint-plugin-vue version: 7.8.0
  • Node version: 14.16.0
  • Operating System: Windows 10 Pro

Please show your full configuration:

module.exports = {
  root: true,
  env: {
    node: true,
  },
  extends: [
    "plugin:vue/essential",
    "eslint:recommended",
    "@vue/typescript/recommended",
    "@vue/prettier",
    "@vue/prettier/@typescript-eslint",
  ],
  parserOptions: {
    ecmaVersion: 2020,
  },
  rules: {},
};

What did you do?

I annotated type to array prop with typescript according to the following documentations.

If the prop is an array, the default should be a function, but I set empty array directly by mistake.

<script lang="ts">
import Vue from "vue";
import { PropType } from "vue";

export default Vue.extend({
  props: {
    foo: {
      type: Array as PropType<string[]>,
      default: [],
    },
  },
});
</script>

What did you expect to happen?

eslint reports type of the default value for 'foo' prop must be a function.

What actually happened?

eslint did not report that. If there is no type assertion, it reports correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions