#Arguments for the rest parameter 'MISMATCH' were not provided.

22 messages · Page 1 of 1 (latest)

stray sedge
#

type OBJItem = {
id?: string | number
label?: string
something?: string
else?: string
content? : string
testValue?: string
value?: string
values? : SomtingLabel[]
}

type SomtingLabel = { value: string; label: string }

renderItem={item => {
expectTypeOf(item).toEqualTypeOf<{ something: string; else: string }>();
return <div>{item.else}</div>;
}}

#

I created general component which take different kind of object with different kind of key combination. I did not get what is wrong here

chilly jungle
#

what do you get when you hover over item?

stray sedge
#

Thanks let me add screen

chilly jungle
#

what's OBJItem

stray sedge
#

I created

type OBJItem = {
id?: string | number
label?: string
something?: string
else?: string
content? : string
testValue?: string
value?: string
values? : SomtingLabel[]
}

type SomtingLabel = { value: string; label: string }

chilly jungle
#

ok firstly

#

toEqualTypeOf checks that the types are exactly the same

#

you probably want toMatchTypeOf

#

but also it still will fail because something and else are optional in OBJItem

stray sedge
#

I need to use items props different way on different place

#

some time id lable

#

so that's why I make it optional

#

is there any other way to create OBJItem

#

I try with

#

`type OBJItem = SomtingLabel|SomthingEles|IdLabel|idValues|ContentTestValue

type SomtingLabel = { value: string; label: string }
type IdLabel = { id: string; label: string }
type SomthingEles = { something: string; else: string; }
type idValues = { id: number; values: SomtingLabel[] }
type ContentTestValue = { content: string; testValue: string }`

#

but that also add same error

stray sedge
#

how can we make overloading object in typescript

stray sedge
#

I get solution by using generic and union