Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

Nesting object declaration

$
0
0

can someone help me with the following snippet.

type Item = {    id: number;    size: number;}type Example = {    name: string;    items: [        Item    ];}var obj: Example = {    name: "test",    items: [        {            id: 1,            size: 10        },        {            id: 2,            size: 34        }    ]}

Actually items should be a list of type Item but i got an error.

Type '[{ id: number; size: number; }, { id: number; size: number; }]'is not assignable to type '[Item]'. Source has 2 element(s) buttarget allows only 1.(2322)


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>