admin管理员组

文章数量:1296307

Hi I'm writing a code using JS and TS. I've made this interface:

> interface IPLTableProps {
>     Conf: [{ key: string, val: any }],
>     Values?: [string],
>     children?: ReactNode // TODO prendere children da React }

I defined this interface for create a general ponent. When I try to use this ponent in another file, obliviously I have to call is as a general ponent. But here it es the error. The general ponent it's called PLTable

 <PLTable Conf={CONF}/>

CONF is an array, and when I try to run I get this error.

TS2741: Property '0' is missing in type '{ label: string; }[]' but required in type '[{ key: string; val: any; }]'.

Can someone help me?

Hi I'm writing a code using JS and TS. I've made this interface:

> interface IPLTableProps {
>     Conf: [{ key: string, val: any }],
>     Values?: [string],
>     children?: ReactNode // TODO prendere children da React }

I defined this interface for create a general ponent. When I try to use this ponent in another file, obliviously I have to call is as a general ponent. But here it es the error. The general ponent it's called PLTable

 <PLTable Conf={CONF}/>

CONF is an array, and when I try to run I get this error.

TS2741: Property '0' is missing in type '{ label: string; }[]' but required in type '[{ key: string; val: any; }]'.

Can someone help me?

Share Improve this question asked Feb 1, 2019 at 10:30 Giovanni GiampaoloGiovanni Giampaolo 4632 gold badges9 silver badges20 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

[type] defines a tuple with a single element. You probably want an array which is defined using type[] or Array<type>

interface IPLTableProps {
    Conf: Array<{ key: string, val: any }>,
    Values?: string[],
    children?: ReactNode 
}

本文标签: htmlTS2741 Property 39039 is missing in type 39 label stringJavascriptStack Overflow