From 13a75c8e4602ab6794d9de51db958633b93c3f1f Mon Sep 17 00:00:00 2001 From: Sergio Date: Fri, 2 Aug 2024 23:50:04 +0200 Subject: [PATCH] Fix type imports --- calc/.eslintrc | 3 ++- calc/src/calc.ts | 8 ++++---- calc/src/data/abilities.ts | 2 +- calc/src/data/index.ts | 2 +- calc/src/data/items.ts | 2 +- calc/src/data/moves.ts | 4 ++-- calc/src/data/natures.ts | 2 +- calc/src/data/species.ts | 4 ++-- calc/src/data/types.ts | 2 +- calc/src/desc.ts | 10 +++++----- calc/src/field.ts | 4 ++-- calc/src/index.ts | 8 ++++---- calc/src/items.ts | 2 +- calc/src/mechanics/gen12.ts | 10 +++++----- calc/src/mechanics/gen3.ts | 10 +++++----- calc/src/mechanics/gen4.ts | 10 +++++----- calc/src/mechanics/gen56.ts | 10 +++++----- calc/src/mechanics/gen789.ts | 10 +++++----- calc/src/mechanics/util.ts | 10 +++++----- calc/src/move.ts | 4 ++-- calc/src/pokemon.ts | 4 ++-- calc/src/result.ts | 10 +++++----- calc/src/state.ts | 2 +- calc/src/stats.ts | 2 +- calc/src/test/calc.test.ts | 2 +- calc/src/test/data.test.ts | 2 +- calc/src/test/gen.ts | 4 ++-- calc/src/test/helper.ts | 6 +++--- calc/src/test/pokemon.test.ts | 2 +- calc/src/test/stats.test.ts | 2 +- calc/src/util.ts | 2 +- 31 files changed, 78 insertions(+), 77 deletions(-) diff --git a/calc/.eslintrc b/calc/.eslintrc index d6d47e1a6..c243240d2 100644 --- a/calc/.eslintrc +++ b/calc/.eslintrc @@ -6,6 +6,7 @@ "@typescript-eslint/no-unused-vars": "off", "jest/no-standalone-expect": "off", "@typescript-eslint/restrict-template-expressions": "off", - "jest/no-conditional-expect": "off" + "jest/no-conditional-expect": "off", + "@typescript-eslint/consistent-type-imports": "error" } } diff --git a/calc/src/calc.ts b/calc/src/calc.ts index f3e53a65c..ac6c13cab 100644 --- a/calc/src/calc.ts +++ b/calc/src/calc.ts @@ -1,8 +1,8 @@ import {Field} from './field'; -import {Generation} from './data/interface'; -import {Move} from './move'; -import {Pokemon} from './pokemon'; -import {Result} from './result'; +import type {Generation} from './data/interface'; +import type {Move} from './move'; +import type {Pokemon} from './pokemon'; +import type {Result} from './result'; import {calculateRBYGSC} from './mechanics/gen12'; import {calculateADV} from './mechanics/gen3'; diff --git a/calc/src/data/abilities.ts b/calc/src/data/abilities.ts index 94898cacc..cee2534bf 100644 --- a/calc/src/data/abilities.ts +++ b/calc/src/data/abilities.ts @@ -1,4 +1,4 @@ -import * as I from './interface'; +import type * as I from './interface'; import {toID} from '../util'; const RBY: string[] = []; diff --git a/calc/src/data/index.ts b/calc/src/data/index.ts index ffb163c5d..5799f6ea7 100644 --- a/calc/src/data/index.ts +++ b/calc/src/data/index.ts @@ -1,4 +1,4 @@ -import * as I from './interface'; +import type * as I from './interface'; import {Abilities} from './abilities'; import {Items} from './items'; diff --git a/calc/src/data/items.ts b/calc/src/data/items.ts index b18cb7532..a09252c67 100644 --- a/calc/src/data/items.ts +++ b/calc/src/data/items.ts @@ -1,4 +1,4 @@ -import * as I from './interface'; +import type * as I from './interface'; import {toID} from '../util'; const RBY: string[] = []; diff --git a/calc/src/data/moves.ts b/calc/src/data/moves.ts index 30e3e9cd2..f3f0eb5c8 100644 --- a/calc/src/data/moves.ts +++ b/calc/src/data/moves.ts @@ -1,5 +1,5 @@ -import * as I from '../data/interface'; -import {toID, DeepPartial, assignWithout, extend} from '../util'; +import type * as I from '../data/interface'; +import {type DeepPartial, toID, assignWithout, extend} from '../util'; export interface MoveData { readonly name?: string; diff --git a/calc/src/data/natures.ts b/calc/src/data/natures.ts index 1c6badf30..f012e6ba3 100644 --- a/calc/src/data/natures.ts +++ b/calc/src/data/natures.ts @@ -1,4 +1,4 @@ -import * as I from './interface'; +import type * as I from './interface'; import {toID} from '../util'; export const NATURES: {[name: string]: [I.StatID, I.StatID]} = { diff --git a/calc/src/data/species.ts b/calc/src/data/species.ts index d61b97bda..e76d3e523 100644 --- a/calc/src/data/species.ts +++ b/calc/src/data/species.ts @@ -1,5 +1,5 @@ -import * as I from './interface'; -import {toID, extend, DeepPartial, assignWithout} from '../util'; +import type * as I from './interface'; +import {type DeepPartial, toID, extend, assignWithout} from '../util'; export interface SpeciesData { readonly types: [I.TypeName] | [I.TypeName, I.TypeName]; diff --git a/calc/src/data/types.ts b/calc/src/data/types.ts index 8298460b8..8335814b9 100644 --- a/calc/src/data/types.ts +++ b/calc/src/data/types.ts @@ -1,4 +1,4 @@ -import * as I from './interface'; +import type * as I from './interface'; import {toID, extend} from '../util'; export type TypeChart = { diff --git a/calc/src/desc.ts b/calc/src/desc.ts index 6c91c0815..9178c7b07 100644 --- a/calc/src/desc.ts +++ b/calc/src/desc.ts @@ -1,8 +1,8 @@ -import {Generation, Weather, Terrain, TypeName, ID} from './data/interface'; -import {Field, Side} from './field'; -import {Move} from './move'; -import {Pokemon} from './pokemon'; -import {Damage, damageRange} from './result'; +import type {Generation, Weather, Terrain, TypeName, ID} from './data/interface'; +import type {Field, Side} from './field'; +import type {Move} from './move'; +import type {Pokemon} from './pokemon'; +import {type Damage, damageRange} from './result'; import {error} from './util'; // NOTE: This needs to come last to simplify bundling import {isGrounded} from './mechanics/util'; diff --git a/calc/src/field.ts b/calc/src/field.ts index 8fa288801..0c759013c 100644 --- a/calc/src/field.ts +++ b/calc/src/field.ts @@ -1,5 +1,5 @@ -import {State} from './state'; -import {GameType, Weather, Terrain} from './data/interface'; +import type {State} from './state'; +import type {GameType, Weather, Terrain} from './data/interface'; export class Field implements State.Field { gameType: GameType; diff --git a/calc/src/index.ts b/calc/src/index.ts index 3940bc84b..bd9d16773 100644 --- a/calc/src/index.ts +++ b/calc/src/index.ts @@ -44,8 +44,8 @@ // that the correct loading order being followed. import {Generations} from './data'; -import {State} from './state'; -import * as I from './data/interface'; +import type {State} from './state'; +import type * as I from './data/interface'; import * as A from './adaptable'; // The loading strategy outlined in the comment above breaks in the browser when we start reusing @@ -142,10 +142,10 @@ export function calcStat( export {Field, Side} from './field'; export {Result} from './result'; -export {GenerationNum, StatsTable, StatID} from './data/interface'; +export {type GenerationNum, type StatsTable, type StatID} from './data/interface'; export {Generations} from './data/index'; export {toID} from './util'; -export {State} from './state'; +export {type State} from './state'; export {ABILITIES} from './data/abilities'; export {ITEMS, MEGA_STONES} from './data/items'; diff --git a/calc/src/items.ts b/calc/src/items.ts index 2ae5affd8..013829f02 100644 --- a/calc/src/items.ts +++ b/calc/src/items.ts @@ -1,4 +1,4 @@ -import {Generation, TypeName, StatID} from './data/interface'; +import type {Generation, TypeName, StatID} from './data/interface'; import {toID} from './util'; export const SEED_BOOSTED_STAT: {[item: string]: StatID} = { diff --git a/calc/src/mechanics/gen12.ts b/calc/src/mechanics/gen12.ts index 78411cddb..325bbc171 100644 --- a/calc/src/mechanics/gen12.ts +++ b/calc/src/mechanics/gen12.ts @@ -1,9 +1,9 @@ -import {Generation} from '../data/interface'; +import type {Generation} from '../data/interface'; import {getItemBoostType} from '../items'; -import {RawDesc} from '../desc'; -import {Field} from '../field'; -import {Move} from '../move'; -import {Pokemon} from '../pokemon'; +import type {RawDesc} from '../desc'; +import type {Field} from '../field'; +import type {Move} from '../move'; +import type {Pokemon} from '../pokemon'; import {Result} from '../result'; import {computeFinalStats, getMoveEffectiveness, handleFixedDamageMoves} from './util'; diff --git a/calc/src/mechanics/gen3.ts b/calc/src/mechanics/gen3.ts index 7aad894bf..c81a09932 100644 --- a/calc/src/mechanics/gen3.ts +++ b/calc/src/mechanics/gen3.ts @@ -1,9 +1,9 @@ -import {Generation} from '../data/interface'; +import type {Generation} from '../data/interface'; import {getItemBoostType} from '../items'; -import {RawDesc} from '../desc'; -import {Pokemon} from '../pokemon'; -import {Move} from '../move'; -import {Field} from '../field'; +import type {RawDesc} from '../desc'; +import type {Pokemon} from '../pokemon'; +import type {Move} from '../move'; +import type {Field} from '../field'; import {Result} from '../result'; import { getModifiedStat, diff --git a/calc/src/mechanics/gen4.ts b/calc/src/mechanics/gen4.ts index 38cfc88bb..a1e3e1eca 100644 --- a/calc/src/mechanics/gen4.ts +++ b/calc/src/mechanics/gen4.ts @@ -1,9 +1,9 @@ -import {Generation, AbilityName} from '../data/interface'; +import type {Generation, AbilityName} from '../data/interface'; import {getItemBoostType, getNaturalGift, getFlingPower, getBerryResistType} from '../items'; -import {RawDesc} from '../desc'; -import {Field} from '../field'; -import {Move} from '../move'; -import {Pokemon} from '../pokemon'; +import type {RawDesc} from '../desc'; +import type {Field} from '../field'; +import type {Move} from '../move'; +import type {Pokemon} from '../pokemon'; import {Result} from '../result'; import { getModifiedStat, diff --git a/calc/src/mechanics/gen56.ts b/calc/src/mechanics/gen56.ts index 0cc1e772e..9f27acd6b 100644 --- a/calc/src/mechanics/gen56.ts +++ b/calc/src/mechanics/gen56.ts @@ -1,4 +1,4 @@ -import {Generation, AbilityName} from '../data/interface'; +import type {Generation, AbilityName} from '../data/interface'; import {toID} from '../util'; import { getItemBoostType, @@ -7,10 +7,10 @@ import { getBerryResistType, getTechnoBlast, } from '../items'; -import {RawDesc} from '../desc'; -import {Field} from '../field'; -import {Move} from '../move'; -import {Pokemon} from '../pokemon'; +import type {RawDesc} from '../desc'; +import type {Field} from '../field'; +import type {Move} from '../move'; +import type {Pokemon} from '../pokemon'; import {Result} from '../result'; import { chainMods, diff --git a/calc/src/mechanics/gen789.ts b/calc/src/mechanics/gen789.ts index ad48f7fe4..cea9d87c9 100644 --- a/calc/src/mechanics/gen789.ts +++ b/calc/src/mechanics/gen789.ts @@ -1,4 +1,4 @@ -import {Generation, AbilityName, StatID, Terrain} from '../data/interface'; +import type {Generation, AbilityName, StatID, Terrain} from '../data/interface'; import {toID} from '../util'; import { getBerryResistType, @@ -9,10 +9,10 @@ import { getTechnoBlast, SEED_BOOSTED_STAT, } from '../items'; -import {RawDesc} from '../desc'; -import {Field} from '../field'; -import {Move} from '../move'; -import {Pokemon} from '../pokemon'; +import type {RawDesc} from '../desc'; +import type {Field} from '../field'; +import type {Move} from '../move'; +import type {Pokemon} from '../pokemon'; import {Result} from '../result'; import { chainMods, diff --git a/calc/src/mechanics/util.ts b/calc/src/mechanics/util.ts index 6145cf884..61caf1ad0 100644 --- a/calc/src/mechanics/util.ts +++ b/calc/src/mechanics/util.ts @@ -1,4 +1,4 @@ -import { +import type { Generation, ID, ItemName, @@ -11,11 +11,11 @@ import { Weather, } from '../data/interface'; import {toID} from '../util'; -import {Field, Side} from '../field'; -import {Move} from '../move'; -import {Pokemon} from '../pokemon'; +import type {Field, Side} from '../field'; +import type {Move} from '../move'; +import type {Pokemon} from '../pokemon'; import {Stats} from '../stats'; -import {RawDesc} from '../desc'; +import type {RawDesc} from '../desc'; const EV_ITEMS = [ 'Macho Brace', diff --git a/calc/src/move.ts b/calc/src/move.ts index a870a676f..47526a57d 100644 --- a/calc/src/move.ts +++ b/calc/src/move.ts @@ -1,5 +1,5 @@ -import * as I from './data/interface'; -import {State} from './state'; +import type * as I from './data/interface'; +import type {State} from './state'; import {toID, extend} from './util'; const SPECIAL = ['Fire', 'Water', 'Grass', 'Electric', 'Ice', 'Psychic', 'Dark', 'Dragon']; diff --git a/calc/src/pokemon.ts b/calc/src/pokemon.ts index e73055860..f34610701 100644 --- a/calc/src/pokemon.ts +++ b/calc/src/pokemon.ts @@ -1,7 +1,7 @@ -import * as I from './data/interface'; +import type * as I from './data/interface'; import {Stats} from './stats'; import {toID, extend, assignWithout} from './util'; -import {State} from './state'; +import type {State} from './state'; const STATS = ['hp', 'atk', 'def', 'spa', 'spd', 'spe'] as I.StatID[]; const SPC = new Set(['spc']); diff --git a/calc/src/result.ts b/calc/src/result.ts index 48ea6e8ce..b895bb159 100644 --- a/calc/src/result.ts +++ b/calc/src/result.ts @@ -1,8 +1,8 @@ -import {RawDesc, display, displayMove, getRecovery, getRecoil, getKOChance} from './desc'; -import {Generation} from './data/interface'; -import {Field} from './field'; -import {Move} from './move'; -import {Pokemon} from './pokemon'; +import {type RawDesc, display, displayMove, getRecovery, getRecoil, getKOChance} from './desc'; +import type {Generation} from './data/interface'; +import type {Field} from './field'; +import type {Move} from './move'; +import type {Pokemon} from './pokemon'; export type Damage = number | number[] | [number, number] | [number[], number[]]; diff --git a/calc/src/state.ts b/calc/src/state.ts index bae70e0ed..bd59b7383 100644 --- a/calc/src/state.ts +++ b/calc/src/state.ts @@ -1,4 +1,4 @@ -import * as I from './data/interface'; +import type * as I from './data/interface'; export namespace State { export interface Pokemon { diff --git a/calc/src/stats.ts b/calc/src/stats.ts index d4274bb00..1507b242f 100644 --- a/calc/src/stats.ts +++ b/calc/src/stats.ts @@ -1,4 +1,4 @@ -import {Natures, Generation, TypeName, StatID, StatsTable} from './data/interface'; +import type {Natures, Generation, TypeName, StatID, StatsTable} from './data/interface'; import {toID} from './util'; const RBY: Array = ['hp', 'atk', 'def', 'spc', 'spe']; diff --git a/calc/src/test/calc.test.ts b/calc/src/test/calc.test.ts index de2728f39..73281a14b 100644 --- a/calc/src/test/calc.test.ts +++ b/calc/src/test/calc.test.ts @@ -1,6 +1,6 @@ /* eslint-disable max-len */ -import {AbilityName, Terrain, Weather} from '../data/interface'; +import type {AbilityName, Terrain, Weather} from '../data/interface'; import {inGen, inGens, tests} from './helper'; describe('calc', () => { diff --git a/calc/src/test/data.test.ts b/calc/src/test/data.test.ts index b3c1874e5..b9d8c7e8d 100644 --- a/calc/src/test/data.test.ts +++ b/calc/src/test/data.test.ts @@ -1,5 +1,5 @@ import {calculate, Pokemon, Move} from '../adaptable'; -import * as I from '../data/interface'; +import type * as I from '../data/interface'; import * as calc from '../index'; import {Dex} from '@pkmn/dex'; diff --git a/calc/src/test/gen.ts b/calc/src/test/gen.ts index 1992cea26..264c54aab 100644 --- a/calc/src/test/gen.ts +++ b/calc/src/test/gen.ts @@ -1,5 +1,5 @@ -import * as I from '../data/interface'; -import * as D from '@pkmn/dex'; +import type * as I from '../data/interface'; +import type * as D from '@pkmn/dex'; export function toID(s: string) { return ('' + s).toLowerCase().replace(/[^a-z0-9]+/g, '') as I.ID; diff --git a/calc/src/test/helper.ts b/calc/src/test/helper.ts index ab85faa75..e980a238d 100644 --- a/calc/src/test/helper.ts +++ b/calc/src/test/helper.ts @@ -1,8 +1,8 @@ /* eslint-env jest */ -import * as I from '../data/interface'; -import {calculate, Pokemon, Move, Result} from '../index'; -import {State} from '../state'; +import type * as I from '../data/interface'; +import {type Result, calculate, Pokemon, Move} from '../index'; +import type {State} from '../state'; import {Field, Side} from '../field'; const calc = (gen: I.GenerationNum) => ( diff --git a/calc/src/test/pokemon.test.ts b/calc/src/test/pokemon.test.ts index eae3faa55..22239a998 100644 --- a/calc/src/test/pokemon.test.ts +++ b/calc/src/test/pokemon.test.ts @@ -1,5 +1,5 @@ import {Pokemon} from '../index'; -import {StatID, MoveName} from '../data/interface'; +import type {StatID, MoveName} from '../data/interface'; describe('Pokemon', () => { test('defaults', () => { diff --git a/calc/src/test/stats.test.ts b/calc/src/test/stats.test.ts index 87b4f648b..9585f0fe2 100644 --- a/calc/src/test/stats.test.ts +++ b/calc/src/test/stats.test.ts @@ -1,5 +1,5 @@ import {Generations} from '../data'; -import {GenerationNum, StatsTable, StatID} from '../data/interface'; +import type {GenerationNum, StatsTable, StatID} from '../data/interface'; import {Stats} from '../stats'; import {getModifiedStat} from '../mechanics/util'; diff --git a/calc/src/util.ts b/calc/src/util.ts index 0202f5a88..4d354fd09 100644 --- a/calc/src/util.ts +++ b/calc/src/util.ts @@ -1,5 +1,5 @@ /* eslint-disable eqeqeq, @typescript-eslint/unbound-method, @typescript-eslint/ban-types */ -import {ID} from './data/interface'; +import type {ID} from './data/interface'; export function toID(text: any): ID { return ('' + text).toLowerCase().replace(/[^a-z0-9]+/g, '') as ID;