Answer the question
In order to leave comments, you need to log in
Typescript type error, how to fix?
Good evening!
I have an interface:
export interface Pokemon {
id: number
name: string
base_experience: number
height: number
is_default: boolean
order: number
weight: number
abilities: object[]
forms: object[]
game_indices: object[]
held_items: object[]
location_area_encounters: string
moves: object[]
sprites: object
species: object
stats: object[]
types: object[]
}
interface PokemonState {
pokemonData: Pokemon;
isLoading: boolean;
isError: string;
}
const initialState: PokemonState = {
pokemonData: {},
isLoading: false,
isError: "",
};
Type '{}' is missing the following properties from type 'Pokemon': id, name, base_experience, height, and 13 more
Answer the question
In order to leave comments, you need to log in
You have an answer at the end of the post - in this case, make the fields optional, or accept a partial object through Partial in your case
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question