Skip to content

Conversation

frozenbonito
Copy link
Contributor

@frozenbonito frozenbonito commented Mar 28, 2021

fix #1468.

This PR ensure that eslint-plugin-vue reports Type of thye default value for 'foo' prop must be function in following case.
(It works the same for Object or Function.)

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

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

Note: In following case, type cheking based on annotated type of the return value of the default function will not work.

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

export default Vue.extend({
  props: {
    foo: {
      type: Array as PropType<string[]>,
      default: (): number[] => [], // The function should return array of string, but this PR can't check it.
    },
  },
});
</script>

Copy link
Member

@ota-meshi ota-meshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you!

@ota-meshi ota-meshi merged commit 26d9920 into vuejs:master Apr 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

False negative with vue/require-valid-default-prop on props with type assertion
2 participants