Skip to content
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

vue-tsc: Component type props false positive #2754

Closed
Lilja opened this issue Apr 28, 2023 · 0 comments
Closed

vue-tsc: Component type props false positive #2754

Lilja opened this issue Apr 28, 2023 · 0 comments
Labels
bug Something isn't working good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first

Comments

@Lilja
Copy link

Lilja commented Apr 28, 2023

Struggling to find the reason why my component can't be used. Based on #1996 it would seem like it's a regression of sorts?

// Table.vue, which uses new vue 3.3 generic type
<script lang="ts" setup generic="Row extends unknown">

const props = defineProps({
    headers: {
        type: Array as PropType<string[]>,
        required: true,
    },
    rows: {
        type: Array as PropType<Row[][]>,
        required: true,
    },
    expand: {
        type: Boolean as PropType<boolean>,
        required: true,
    },
    identifierIndex: {
        type: Number as PropType<number>,
        required: true,
    },
    animationRows: {
        type: Array as PropType<number[]>,
        required: false,
        default: [],
    },
    checkbox: {
        type: Boolean as PropType<boolean>,
        required: false,
        default: false,
    },
    selectAll: {
        type: Boolean as PropType<boolean>,
        required: false,
        default: false,
    },
    stickyHeader: {
        type: Boolean as PropType<boolean>,
        required: false,
        default: false,
    },
});
const headers: string[] = ["Date", "String", "Number"];
type Row = Date | string | number;
const rows = computed(() => [[new Date(), "hi", 50]] as Row[][]);
<Table
    :headers="headers"
    :rows="tableRows"
    :expand="true"
    :identifierIndex="2"
    :checkbox="false"
    @headerClick="setSortKey"
>
Argument of type '{ headers: string[]; rows: Row[][]; identifierIndex: number; expand: true; checkbox: false; }' is not assignable to parameter of type 'Readonly<ExtractPropTypes<{ headers: { type: PropType<string[]>; required: true; }; rows: { type: PropType<Row[][]>; required: true; }; expand: { type: PropType<boolean>; required: true; }; identifierIndex: { type: PropType<number>; required: true; }; animationRows: { type: PropType<number[]>; required: false; default: never[]; }; checkbox: { type: PropType<boolean>; required: false; default: boolean; }; selectAll: { type: PropType<boolean>; required: false; default: boolean; }; stickyHeader: { type: PropType<boolean>; required: false; default: boolean; }; }>> & VNodeProps & AllowedComponentProps & ComponentCustomProps'.
  Type '{ headers: string[]; rows: Row[][]; identifierIndex: number; expand: true; checkbox: false; }' is missing the following properties from type 'Readonly<ExtractPropTypes<{ headers: { type: PropType<string[]>; required: true; }; rows: { type: PropType<Row[][]>; required: true; }; expand: { type: PropType<boolean>; required: true; }; identifierIndex: { type: PropType<number>; required: true; }; animationRows: { type: PropType<number[]>; required: false; default: never[]; }; checkbox: { type: PropType<boolean>; required: false; default: boolean; }; selectAll: { type: PropType<boolean>; required: false; default: boolean; }; stickyHeader: { type: PropType<boolean>; required: false; default: boolean; }; }>>': animationRows, selectAll, stickyHeader
$ yarn vue-tsc --version
Version 4.8.3
{
  "dependencies": {
    "vue-tsc": "1.6.1"
  }
}
@Lilja Lilja changed the title Component type props false positive vue-tsc: Component type props false positive Apr 28, 2023
@johnsoncodehk johnsoncodehk added bug Something isn't working upstream and removed upstream labels May 1, 2023
@johnsoncodehk johnsoncodehk added the good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first label May 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first
Projects
None yet
Development

No branches or pull requests

2 participants