Trying to use type alis extension to replace overlap interface definition

This commit is contained in:
Jason Zhu 2023-05-20 12:42:04 +10:00
parent 768c84d6b8
commit bf3cbe886b
2 changed files with 8 additions and 21 deletions

View File

@ -7,31 +7,18 @@ import { findPokeTypeAsset } from 'components/PokemonTypes';
import { colorTypeGradients } from 'components/utils'; import { colorTypeGradients } from 'components/utils';
import GenderRate from 'components/GenderRate'; import GenderRate from 'components/GenderRate';
import Delayed from 'components/Delayed'; import Delayed from 'components/Delayed';
import EvolutionSpecies, { import EvolutionSpecies from 'components/EvolutionSpecies';
EvolutionSpeciesProps, import { InfoDialogDetails } from 'features/InfoDialog/infoDialogSlice';
} from 'components/EvolutionSpecies';
export interface Stat { export interface Stat {
stat__name: string; stat__name: string;
stat__value: number; stat__value: number;
} }
export interface InfoDialogComponentProps { export type InfoDialogComponentProps = InfoDialogDetails & {
openDialog: boolean; openDialog: boolean;
closeDialog: () => void; closeDialog: () => void;
id: number; };
name: string;
types: string[];
genera: string;
image: string;
height: number;
weight: number;
genderRatio: number;
description: string;
abilities: string[];
stats: Stat[];
evolutionChain: EvolutionSpeciesProps[];
}
const InfoDialog = ({ const InfoDialog = ({
openDialog, openDialog,

View File

@ -13,7 +13,7 @@ import {
PokemonSpeciesResponseData, PokemonSpeciesResponseData,
} from 'types/api'; } from 'types/api';
type InfoDiaglogDetails = { export type InfoDialogDetails = {
id: number; id: number;
name: string; name: string;
genera: string; genera: string;
@ -28,7 +28,7 @@ type InfoDiaglogDetails = {
evolutionChain: EvolutionSpeciesProps[]; evolutionChain: EvolutionSpeciesProps[];
}; };
const initialInfoDialogDetails: InfoDiaglogDetails = { const initialInfoDialogDetails: InfoDialogDetails = {
id: 0, id: 0,
name: '', name: '',
genera: '', genera: '',
@ -45,7 +45,7 @@ const initialInfoDialogDetails: InfoDiaglogDetails = {
export type InfoDialogStateProps = { export type InfoDialogStateProps = {
isOpen: boolean; isOpen: boolean;
InfoDialogDetails: InfoDiaglogDetails; InfoDialogDetails: InfoDialogDetails;
}; };
export const initialState: InfoDialogStateProps = { export const initialState: InfoDialogStateProps = {
@ -90,7 +90,7 @@ export const constructPokemonInfoFromResponses = (
fetchedPokemon: PokemonResponseData, fetchedPokemon: PokemonResponseData,
fetchedPokemonSpecies: PokemonSpeciesResponseData, fetchedPokemonSpecies: PokemonSpeciesResponseData,
evolutionChain: EvolutionSpeciesProps[], evolutionChain: EvolutionSpeciesProps[],
): InfoDiaglogDetails => { ): InfoDialogDetails => {
return { return {
id: fetchedPokemon.id, id: fetchedPokemon.id,
name: fetchedPokemon.name, name: fetchedPokemon.name,