Reputation: 860
I have an interface as follows:
interface Order {
symbol: string
side: string
price: number
quantity: number
}
I have a line in my code where I am accessing values in a table. However, it complains and says that d.symbol is not assignable to a string.
accessor: (d: Order) : Order => d.symbol
Does anyone know how I can work around this?
Upvotes: 0
Views: 1819
Reputation: 1
You returned a string when you declared that the return type is Order
.
Solution: change the return type to string
.
Upvotes: 0
Reputation: 220894
(d: Order) : Order => d.symbol
This line means "A function accepting one argument (d
) of type Order
that returns an Order
".
Your function returns a string
, not an Order
.
You can fix the return type annotation
(d: Order) : string => d.symbol
Or remove it
(d: Order) => d.symbol
Or return the correct kind of thing, if that's what was actually intended
(d: Order) : Order => d
Upvotes: 2