My first day building something with React + TS.
I'm trying to make use of a 'dictionary' to convert a string into another.
import { eventDictionary } from '../utils/eventDictionary'
type Props = {
id: string
type: string
}
const GameCard: React.FC<Props> = ({id, type}) => {
return (
<div key={id}>
<h3>{eventDictionary[type]}</h3>
<h3>{type}</h3>
</div>
)
}
And this is the dictionary:
bsk: "basketball",
foot: "football",
tenn: "tennis"
}
But I'm getting:
Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ bsk: string; foot: string; tenn: string; }'.
No index signature with a parameter of type 'string' was found on type '{ bsk: string; foot: string; tenn: string; }'.
What am I doing wrong?