From 6b630753f0dca683594eb8f8a11586940e82855c Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Thu, 14 Jul 2022 19:00:10 -0400 Subject: [PATCH] nuke some use of any --- src/Augmentation/Augmentation.tsx | 7 +++---- src/Bladeburner/Action.tsx | 7 +++---- src/Bladeburner/ActionIdentifier.ts | 7 +++---- src/Bladeburner/BlackOperation.ts | 7 +++---- src/Bladeburner/Bladeburner.tsx | 7 +++---- src/Bladeburner/City.ts | 7 +++---- src/Bladeburner/Contract.ts | 7 +++---- src/Bladeburner/IAction.tsx | 3 ++- src/Bladeburner/Operation.ts | 7 +++---- src/CodingContracts.ts | 7 +++---- src/Company/Company.ts | 7 +++---- src/Corporation/Corporation.tsx | 7 +++---- src/Corporation/CorporationState.ts | 7 +++---- src/Corporation/Employee.ts | 7 +++---- src/Corporation/ICorporation.ts | 3 ++- src/Corporation/IIndustry.ts | 3 ++- src/Corporation/Industry.ts | 7 +++---- src/Corporation/Material.ts | 7 +++---- src/Corporation/OfficeSpace.ts | 7 +++---- src/Corporation/Product.ts | 7 +++---- src/Corporation/Warehouse.ts | 7 +++---- src/CotMG/ActiveFragment.ts | 7 +++---- src/CotMG/DummyGift.ts | 12 ++++++------ src/CotMG/StaneksGift.ts | 7 +++---- src/Faction/Faction.ts | 7 +++---- src/Gang/Gang.ts | 7 +++---- src/Gang/GangMember.ts | 7 +++---- src/Gang/IGang.ts | 3 ++- src/Hacknet/HacknetNode.ts | 7 +++---- src/Hacknet/HacknetServer.ts | 7 +++---- src/Hacknet/HashManager.ts | 7 +++---- src/PersonObjects/Player/PlayerObject.ts | 7 +++---- src/PersonObjects/Sleeve/Sleeve.ts | 7 +++---- src/SaveObject.tsx | 6 +++--- src/Script/RunningScript.ts | 7 +++---- src/Script/Script.ts | 7 +++---- src/Server/Server.ts | 7 +++---- src/StockMarket/Order.ts | 7 +++---- src/StockMarket/Stock.ts | 9 ++++----- src/TextFile.ts | 9 ++++----- src/utils/MoneySourceTracker.ts | 3 +-- 41 files changed, 122 insertions(+), 153 deletions(-) diff --git a/src/Augmentation/Augmentation.tsx b/src/Augmentation/Augmentation.tsx index d685028e0..4530ec80a 100644 --- a/src/Augmentation/Augmentation.tsx +++ b/src/Augmentation/Augmentation.tsx @@ -7,7 +7,7 @@ import { Factions } from "../Faction/Factions"; import { numeralWrapper } from "../ui/numeralFormat"; import { Money } from "../ui/React/Money"; -import { Generic_fromJSON, Generic_toJSON, Reviver } from "../utils/JSONReviver"; +import { Generic_fromJSON, Generic_toJSON, IReviverValue, Reviver } from "../utils/JSONReviver"; import { FactionNames } from "../Faction/data/FactionNames"; import { IPlayer } from "../PersonObjects/IPlayer"; import { AugmentationNames } from "./data/AugmentationNames"; @@ -610,13 +610,12 @@ export class Augmentation { } // Serialize the current object to a JSON save state. - toJSON(): any { + toJSON(): IReviverValue { return Generic_toJSON("Augmentation", this); } // Initiatizes a Augmentation object from a JSON save state. - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types - static fromJSON(value: any): Augmentation { + static fromJSON(value: IReviverValue): Augmentation { return Generic_fromJSON(Augmentation, value.data); } } diff --git a/src/Bladeburner/Action.tsx b/src/Bladeburner/Action.tsx index 1bd6d5dcf..21ca7b494 100644 --- a/src/Bladeburner/Action.tsx +++ b/src/Bladeburner/Action.tsx @@ -1,7 +1,7 @@ import { Player } from "../Player"; import { getRandomInt } from "../utils/helpers/getRandomInt"; import { addOffset } from "../utils/helpers/addOffset"; -import { Generic_fromJSON, Generic_toJSON, Reviver } from "../utils/JSONReviver"; +import { Generic_fromJSON, Generic_toJSON, IReviverValue, Reviver } from "../utils/JSONReviver"; import { BladeburnerConstants } from "./data/Constants"; import { IBladeburner } from "./IBladeburner"; import { IAction, ISuccessChanceParams } from "./IAction"; @@ -292,12 +292,11 @@ export class Action implements IAction { } } - toJSON(): any { + toJSON(): IReviverValue { return Generic_toJSON("Action", this); } - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types - static fromJSON(value: any): Action { + static fromJSON(value: IReviverValue): Action { return Generic_fromJSON(Action, value.data); } } diff --git a/src/Bladeburner/ActionIdentifier.ts b/src/Bladeburner/ActionIdentifier.ts index 07a3c9634..9368bb874 100644 --- a/src/Bladeburner/ActionIdentifier.ts +++ b/src/Bladeburner/ActionIdentifier.ts @@ -1,5 +1,5 @@ import { IActionIdentifier } from "./IActionIdentifier"; -import { Generic_fromJSON, Generic_toJSON, Reviver } from "../utils/JSONReviver"; +import { Generic_fromJSON, Generic_toJSON, IReviverValue, Reviver } from "../utils/JSONReviver"; interface IParams { name?: string; @@ -15,12 +15,11 @@ export class ActionIdentifier implements IActionIdentifier { if (params.type) this.type = params.type; } - toJSON(): any { + toJSON(): IReviverValue { return Generic_toJSON("ActionIdentifier", this); } - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types - static fromJSON(value: any): ActionIdentifier { + static fromJSON(value: IReviverValue): ActionIdentifier { return Generic_fromJSON(ActionIdentifier, value.data); } } diff --git a/src/Bladeburner/BlackOperation.ts b/src/Bladeburner/BlackOperation.ts index 8bc9958ca..9691ba5c6 100644 --- a/src/Bladeburner/BlackOperation.ts +++ b/src/Bladeburner/BlackOperation.ts @@ -1,5 +1,5 @@ import { Operation, IOperationParams } from "./Operation"; -import { Generic_fromJSON, Generic_toJSON, Reviver } from "../utils/JSONReviver"; +import { Generic_fromJSON, Generic_toJSON, IReviverValue, Reviver } from "../utils/JSONReviver"; export class BlackOperation extends Operation { constructor(params: IOperationParams | null = null) { @@ -20,12 +20,11 @@ export class BlackOperation extends Operation { return 1; } - toJSON(): any { + toJSON(): IReviverValue { return Generic_toJSON("BlackOperation", this); } - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types - static fromJSON(value: any): Operation { + static fromJSON(value: IReviverValue): Operation { return Generic_fromJSON(BlackOperation, value.data); } } diff --git a/src/Bladeburner/Bladeburner.tsx b/src/Bladeburner/Bladeburner.tsx index 3a1c95b83..adcbb9397 100644 --- a/src/Bladeburner/Bladeburner.tsx +++ b/src/Bladeburner/Bladeburner.tsx @@ -1,4 +1,4 @@ -import { Reviver, Generic_toJSON, Generic_fromJSON } from "../utils/JSONReviver"; +import { Reviver, Generic_toJSON, Generic_fromJSON, IReviverValue } from "../utils/JSONReviver"; import { IBladeburner } from "./IBladeburner"; import { IActionIdentifier } from "./IActionIdentifier"; import { ActionIdentifier } from "./ActionIdentifier"; @@ -2409,15 +2409,14 @@ export class Bladeburner implements IBladeburner { /** * Serialize the current object to a JSON save state. */ - toJSON(): any { + toJSON(): IReviverValue { return Generic_toJSON("Bladeburner", this); } /** * Initiatizes a Bladeburner object from a JSON save state. */ - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types - static fromJSON(value: any): Bladeburner { + static fromJSON(value: IReviverValue): Bladeburner { return Generic_fromJSON(Bladeburner, value.data); } } diff --git a/src/Bladeburner/City.ts b/src/Bladeburner/City.ts index 7e171d2a0..7ead8c7e5 100644 --- a/src/Bladeburner/City.ts +++ b/src/Bladeburner/City.ts @@ -1,6 +1,6 @@ import { BladeburnerConstants } from "./data/Constants"; import { getRandomInt } from "../utils/helpers/getRandomInt"; -import { Generic_fromJSON, Generic_toJSON, Reviver } from "../utils/JSONReviver"; +import { Generic_fromJSON, Generic_toJSON, IReviverValue, Reviver } from "../utils/JSONReviver"; import { addOffset } from "../utils/helpers/addOffset"; interface IChangePopulationByCountParams { @@ -177,15 +177,14 @@ export class City { /** * Serialize the current object to a JSON save state. */ - toJSON(): any { + toJSON(): IReviverValue { return Generic_toJSON("City", this); } /** * Initiatizes a City object from a JSON save state. */ - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types - static fromJSON(value: any): City { + static fromJSON(value: IReviverValue): City { return Generic_fromJSON(City, value.data); } } diff --git a/src/Bladeburner/Contract.ts b/src/Bladeburner/Contract.ts index aea403f81..a74d1b029 100644 --- a/src/Bladeburner/Contract.ts +++ b/src/Bladeburner/Contract.ts @@ -1,6 +1,6 @@ import { IBladeburner } from "./IBladeburner"; import { Action, IActionParams } from "./Action"; -import { Generic_fromJSON, Generic_toJSON, Reviver } from "../utils/JSONReviver"; +import { Generic_fromJSON, Generic_toJSON, IReviverValue, Reviver } from "../utils/JSONReviver"; export class Contract extends Action { constructor(params: IActionParams | null = null) { @@ -11,12 +11,11 @@ export class Contract extends Action { return inst.skillMultipliers.successChanceContract; } - toJSON(): any { + toJSON(): IReviverValue { return Generic_toJSON("Contract", this); } - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types - static fromJSON(value: any): Contract { + static fromJSON(value: IReviverValue): Contract { return Generic_fromJSON(Contract, value.data); } } diff --git a/src/Bladeburner/IAction.tsx b/src/Bladeburner/IAction.tsx index 666ffbfe9..55202d638 100644 --- a/src/Bladeburner/IAction.tsx +++ b/src/Bladeburner/IAction.tsx @@ -1,3 +1,4 @@ +import { IReviverValue } from "../utils/JSONReviver"; import { IPerson } from "../PersonObjects/IPerson"; import { IBladeburner } from "./IBladeburner"; @@ -67,5 +68,5 @@ export interface IAction { getSuccessChance(inst: IBladeburner, person: IPerson, params: ISuccessChanceParams): number; getSuccessesNeededForNextLevel(baseSuccessesPerLevel: number): number; setMaxLevel(baseSuccessesPerLevel: number): void; - toJSON(): any; + toJSON(): IReviverValue; } diff --git a/src/Bladeburner/Operation.ts b/src/Bladeburner/Operation.ts index 5066839f3..04304988e 100644 --- a/src/Bladeburner/Operation.ts +++ b/src/Bladeburner/Operation.ts @@ -1,7 +1,7 @@ import { IBladeburner } from "./IBladeburner"; import { BladeburnerConstants } from "./data/Constants"; import { Action, IActionParams } from "./Action"; -import { Generic_fromJSON, Generic_toJSON, Reviver } from "../utils/JSONReviver"; +import { Generic_fromJSON, Generic_toJSON, IReviverValue, Reviver } from "../utils/JSONReviver"; export interface IOperationParams extends IActionParams { reqdRank?: number; @@ -44,12 +44,11 @@ export class Operation extends Action { return 1; } - toJSON(): any { + toJSON(): IReviverValue { return Generic_toJSON("Operation", this); } - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types - static fromJSON(value: any): Operation { + static fromJSON(value: IReviverValue): Operation { return Generic_fromJSON(Operation, value.data); } } diff --git a/src/CodingContracts.ts b/src/CodingContracts.ts index 68a9e3103..a0889bc93 100644 --- a/src/CodingContracts.ts +++ b/src/CodingContracts.ts @@ -2,7 +2,7 @@ import { codingContractTypesMetadata, DescriptionFunc, GeneratorFunc, SolverFunc import { IMap } from "./types"; -import { Generic_fromJSON, Generic_toJSON, Reviver } from "./utils/JSONReviver"; +import { Generic_fromJSON, Generic_toJSON, IReviverValue, Reviver } from "./utils/JSONReviver"; import { CodingContractEvent } from "./ui/React/CodingContractModal"; /* tslint:disable:no-magic-numbers completed-docs max-classes-per-file no-console */ @@ -186,15 +186,14 @@ export class CodingContract { /** * Serialize the current file to a JSON save state. */ - toJSON(): any { + toJSON(): IReviverValue { return Generic_toJSON("CodingContract", this); } /** * Initiatizes a CodingContract from a JSON save state. */ - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types - static fromJSON(value: any): CodingContract { + static fromJSON(value: IReviverValue): CodingContract { return Generic_fromJSON(CodingContract, value.data); } } diff --git a/src/Company/Company.ts b/src/Company/Company.ts index 9569964e6..49473c6d4 100644 --- a/src/Company/Company.ts +++ b/src/Company/Company.ts @@ -4,7 +4,7 @@ import { favorToRep, repToFavor } from "../Faction/formulas/favor"; import { IMap } from "../types"; -import { Generic_fromJSON, Generic_toJSON, Reviver } from "../utils/JSONReviver"; +import { Generic_fromJSON, Generic_toJSON, IReviverValue, Reviver } from "../utils/JSONReviver"; export interface IConstructorParams { name: string; @@ -151,15 +151,14 @@ export class Company { /** * Serialize the current object to a JSON save state. */ - toJSON(): any { + toJSON(): IReviverValue { return Generic_toJSON("Company", this); } /** * Initiatizes a Company from a JSON save state. */ - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types - static fromJSON(value: any): Company { + static fromJSON(value: IReviverValue): Company { return Generic_fromJSON(Company, value.data); } } diff --git a/src/Corporation/Corporation.tsx b/src/Corporation/Corporation.tsx index ace40ae72..820913234 100644 --- a/src/Corporation/Corporation.tsx +++ b/src/Corporation/Corporation.tsx @@ -11,7 +11,7 @@ import { LiteratureNames } from "../Literature/data/LiteratureNames"; import { IPlayer } from "../PersonObjects/IPlayer"; import { dialogBoxCreate } from "../ui/React/DialogBox"; -import { Reviver, Generic_toJSON, Generic_fromJSON } from "../utils/JSONReviver"; +import { Reviver, Generic_toJSON, Generic_fromJSON, IReviverValue } from "../utils/JSONReviver"; import { isString } from "../utils/helpers/isString"; interface IParams { @@ -433,15 +433,14 @@ export class Corporation { /** * Serialize the current object to a JSON save state. */ - toJSON(): any { + toJSON(): IReviverValue { return Generic_toJSON("Corporation", this); } /** * Initiatizes a Corporation object from a JSON save state. */ - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types - static fromJSON(value: any): Corporation { + static fromJSON(value: IReviverValue): Corporation { return Generic_fromJSON(Corporation, value.data); } } diff --git a/src/Corporation/CorporationState.ts b/src/Corporation/CorporationState.ts index b6c7903ba..bdf8c6c02 100644 --- a/src/Corporation/CorporationState.ts +++ b/src/Corporation/CorporationState.ts @@ -1,4 +1,4 @@ -import { Generic_fromJSON, Generic_toJSON, Reviver } from "../utils/JSONReviver"; +import { Generic_fromJSON, Generic_toJSON, IReviverValue, Reviver } from "../utils/JSONReviver"; // Array of all valid states const AllCorporationStates: string[] = ["START", "PURCHASE", "PRODUCTION", "SALE", "EXPORT"]; @@ -28,13 +28,12 @@ export class CorporationState { } // Serialize the current object to a JSON save state. - toJSON(): any { + toJSON(): IReviverValue { return Generic_toJSON("CorporationState", this); } // Initiatizes a CorporationState object from a JSON save state. - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types - static fromJSON(value: any): CorporationState { + static fromJSON(value: IReviverValue): CorporationState { return Generic_fromJSON(CorporationState, value.data); } } diff --git a/src/Corporation/Employee.ts b/src/Corporation/Employee.ts index 60a08f202..8f3e13b1d 100644 --- a/src/Corporation/Employee.ts +++ b/src/Corporation/Employee.ts @@ -1,6 +1,6 @@ import { CorporationConstants } from "./data/Constants"; import { getRandomInt } from "../utils/helpers/getRandomInt"; -import { Generic_fromJSON, Generic_toJSON, Reviver } from "../utils/JSONReviver"; +import { Generic_fromJSON, Generic_toJSON, IReviverValue, Reviver } from "../utils/JSONReviver"; import { EmployeePositions } from "./EmployeePositions"; import { ICorporation } from "./ICorporation"; import { OfficeSpace } from "./OfficeSpace"; @@ -128,12 +128,11 @@ export class Employee { return mult; } - toJSON(): any { + toJSON(): IReviverValue { return Generic_toJSON("Employee", this); } - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types - static fromJSON(value: any): Employee { + static fromJSON(value: IReviverValue): Employee { return Generic_fromJSON(Employee, value.data); } } diff --git a/src/Corporation/ICorporation.ts b/src/Corporation/ICorporation.ts index 609204fee..72f829273 100644 --- a/src/Corporation/ICorporation.ts +++ b/src/Corporation/ICorporation.ts @@ -3,6 +3,7 @@ import { IPlayer } from "../PersonObjects/IPlayer"; import { CorporationUnlockUpgrade } from "./data/CorporationUnlockUpgrades"; import { CorporationUpgrade } from "./data/CorporationUpgrades"; import { CorporationState } from "./CorporationState"; +import { IReviverValue } from "../utils/JSONReviver"; export interface ICorporation { name: string; @@ -54,6 +55,6 @@ export interface ICorporation { getSalesMultiplier(): number; getScientificResearchMultiplier(): number; getStarterGuide(player: IPlayer): void; - toJSON(): any; + toJSON(): IReviverValue; getDividends(): number; } diff --git a/src/Corporation/IIndustry.ts b/src/Corporation/IIndustry.ts index 1cb5737ea..02c418ad2 100644 --- a/src/Corporation/IIndustry.ts +++ b/src/Corporation/IIndustry.ts @@ -4,6 +4,7 @@ import { ICorporation } from "./ICorporation"; import { OfficeSpace } from "./OfficeSpace"; import { Product } from "./Product"; import { IndustryUpgrade } from "./IndustryUpgrades"; +import { IReviverValue } from "../utils/JSONReviver"; export interface IIndustry { name: string; @@ -73,5 +74,5 @@ export interface IIndustry { getSalesMultiplier(): number; getScientificResearchMultiplier(): number; getStorageMultiplier(): number; - toJSON(): any; + toJSON(): IReviverValue; } diff --git a/src/Corporation/Industry.ts b/src/Corporation/Industry.ts index f2a12e129..d149bded3 100644 --- a/src/Corporation/Industry.ts +++ b/src/Corporation/Industry.ts @@ -1,4 +1,4 @@ -import { Reviver, Generic_toJSON, Generic_fromJSON } from "../utils/JSONReviver"; +import { Reviver, Generic_toJSON, Generic_fromJSON, IReviverValue } from "../utils/JSONReviver"; import { CityName } from "../Locations/data/CityNames"; import { Industries, IndustryStartingCosts, IndustryResearchTrees } from "./IndustryData"; import { CorporationConstants } from "./data/Constants"; @@ -1438,15 +1438,14 @@ export class Industry implements IIndustry { /** * Serialize the current object to a JSON save state. */ - toJSON(): any { + toJSON(): IReviverValue { return Generic_toJSON("Industry", this); } /** * Initiatizes a Industry object from a JSON save state. */ - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types - static fromJSON(value: any): Industry { + static fromJSON(value: IReviverValue): Industry { return Generic_fromJSON(Industry, value.data); } } diff --git a/src/Corporation/Material.ts b/src/Corporation/Material.ts index fed9b4208..5db260489 100644 --- a/src/Corporation/Material.ts +++ b/src/Corporation/Material.ts @@ -1,4 +1,4 @@ -import { Generic_fromJSON, Generic_toJSON, Reviver } from "../utils/JSONReviver"; +import { Generic_fromJSON, Generic_toJSON, IReviverValue, Reviver } from "../utils/JSONReviver"; import { Export } from "./Export"; interface IConstructorParams { @@ -229,13 +229,12 @@ export class Material { } // Serialize the current object to a JSON save state. - toJSON(): any { + toJSON(): IReviverValue { return Generic_toJSON("Material", this); } // Initiatizes a Material object from a JSON save state. - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types - static fromJSON(value: any): Material { + static fromJSON(value: IReviverValue): Material { return Generic_fromJSON(Material, value.data); } } diff --git a/src/Corporation/OfficeSpace.ts b/src/Corporation/OfficeSpace.ts index 623b3c5d3..ab667e692 100644 --- a/src/Corporation/OfficeSpace.ts +++ b/src/Corporation/OfficeSpace.ts @@ -2,7 +2,7 @@ import { EmployeePositions } from "./EmployeePositions"; import { CorporationConstants } from "./data/Constants"; import { getRandomInt } from "../utils/helpers/getRandomInt"; import { generateRandomString } from "../utils/StringHelperFunctions"; -import { Generic_fromJSON, Generic_toJSON, Reviver } from "../utils/JSONReviver"; +import { Generic_fromJSON, Generic_toJSON, IReviverValue, Reviver } from "../utils/JSONReviver"; import { Employee } from "./Employee"; import { IIndustry } from "./IIndustry"; import { ICorporation } from "./ICorporation"; @@ -214,12 +214,11 @@ export class OfficeSpace { return jobCount === amount; } - toJSON(): any { + toJSON(): IReviverValue { return Generic_toJSON("OfficeSpace", this); } - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types - static fromJSON(value: any): OfficeSpace { + static fromJSON(value: IReviverValue): OfficeSpace { return Generic_fromJSON(OfficeSpace, value.data); } } diff --git a/src/Corporation/Product.ts b/src/Corporation/Product.ts index cfe15917f..5985e228f 100644 --- a/src/Corporation/Product.ts +++ b/src/Corporation/Product.ts @@ -6,7 +6,7 @@ import { ProductRatingWeights, IProductRatingWeight } from "./ProductRatingWeigh import { createCityMap } from "../Locations/createCityMap"; import { IMap } from "../types"; -import { Generic_fromJSON, Generic_toJSON, Reviver } from "../utils/JSONReviver"; +import { Generic_fromJSON, Generic_toJSON, IReviverValue, Reviver } from "../utils/JSONReviver"; import { getRandomInt } from "../utils/helpers/getRandomInt"; interface IConstructorParams { @@ -232,13 +232,12 @@ export class Product { } // Serialize the current object to a JSON save state. - toJSON(): any { + toJSON(): IReviverValue { return Generic_toJSON("Product", this); } // Initiatizes a Product object from a JSON save state. - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types - static fromJSON(value: any): Product { + static fromJSON(value: IReviverValue): Product { return Generic_fromJSON(Product, value.data); } } diff --git a/src/Corporation/Warehouse.ts b/src/Corporation/Warehouse.ts index d55a641c6..a37b7479b 100644 --- a/src/Corporation/Warehouse.ts +++ b/src/Corporation/Warehouse.ts @@ -3,7 +3,7 @@ import { ICorporation } from "./ICorporation"; import { IIndustry } from "./IIndustry"; import { MaterialSizes } from "./MaterialSizes"; import { IMap } from "../types"; -import { Generic_fromJSON, Generic_toJSON, Reviver } from "../utils/JSONReviver"; +import { Generic_fromJSON, Generic_toJSON, IReviverValue, Reviver } from "../utils/JSONReviver"; import { exceptionAlert } from "../utils/helpers/exceptionAlert"; interface IConstructorParams { @@ -105,13 +105,12 @@ export class Warehouse { } // Serialize the current object to a JSON save state. - toJSON(): any { + toJSON(): IReviverValue { return Generic_toJSON("Warehouse", this); } // Initiatizes a Warehouse object from a JSON save state. - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types - static fromJSON(value: any): Warehouse { + static fromJSON(value: IReviverValue): Warehouse { return Generic_fromJSON(Warehouse, value.data); } } diff --git a/src/CotMG/ActiveFragment.ts b/src/CotMG/ActiveFragment.ts index b09483c55..10bee93b4 100644 --- a/src/CotMG/ActiveFragment.ts +++ b/src/CotMG/ActiveFragment.ts @@ -1,5 +1,5 @@ import { Fragment, FragmentById } from "./Fragment"; -import { Generic_fromJSON, Generic_toJSON, Reviver } from "../utils/JSONReviver"; +import { Generic_fromJSON, Generic_toJSON, IReviverValue, Reviver } from "../utils/JSONReviver"; export interface IActiveFragmentParams { x: number; @@ -74,15 +74,14 @@ export class ActiveFragment { /** * Serialize an active fragment to a JSON save state. */ - toJSON(): any { + toJSON(): IReviverValue { return Generic_toJSON("ActiveFragment", this); } /** * Initializes an acive fragment from a JSON save state */ - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types - static fromJSON(value: any): ActiveFragment { + static fromJSON(value: IReviverValue): ActiveFragment { return Generic_fromJSON(ActiveFragment, value.data); } } diff --git a/src/CotMG/DummyGift.ts b/src/CotMG/DummyGift.ts index 79b541e72..eb80815be 100644 --- a/src/CotMG/DummyGift.ts +++ b/src/CotMG/DummyGift.ts @@ -19,22 +19,22 @@ export class DummyGift implements IStaneksGift { height(): number { return this._height; } - charge(): any { + charge(): void { throw new Error("unimplemented for dummy gift"); } - process(): any { + process(): void { throw new Error("unimplemented for dummy gift"); } - effect(): any { + effect(): number { throw new Error("unimplemented for dummy gift"); } - canPlace(): any { + canPlace(): boolean { throw new Error("unimplemented for dummy gift"); } - place(): any { + place(): boolean { throw new Error("unimplemented for dummy gift"); } - findFragment(): any { + findFragment(): ActiveFragment | undefined { throw new Error("unimplemented for dummy gift"); } fragmentAt(worldX: number, worldY: number): ActiveFragment | undefined { diff --git a/src/CotMG/StaneksGift.ts b/src/CotMG/StaneksGift.ts index 0ce6ff1bd..4858bb64c 100644 --- a/src/CotMG/StaneksGift.ts +++ b/src/CotMG/StaneksGift.ts @@ -7,7 +7,7 @@ import { IPlayer } from "../PersonObjects/IPlayer"; import { Factions } from "../Faction/Factions"; import { CalculateEffect } from "./formulas/effect"; import { StaneksGiftEvents } from "./StaneksGiftEvents"; -import { Generic_fromJSON, Generic_toJSON, Reviver } from "../utils/JSONReviver"; +import { Generic_fromJSON, Generic_toJSON, IReviverValue, Reviver } from "../utils/JSONReviver"; import { CONSTANTS } from "../Constants"; import { StanekConstants } from "./data/Constants"; import { BitNodeMultipliers } from "../BitNode/BitNodeMultipliers"; @@ -224,15 +224,14 @@ export class StaneksGift implements IStaneksGift { /** * Serialize Staneks Gift to a JSON save state. */ - toJSON(): any { + toJSON(): IReviverValue { return Generic_toJSON("StaneksGift", this); } /** * Initializes Staneks Gift from a JSON save state */ - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types - static fromJSON(value: any): StaneksGift { + static fromJSON(value: IReviverValue): StaneksGift { return Generic_fromJSON(StaneksGift, value.data); } } diff --git a/src/Faction/Faction.ts b/src/Faction/Faction.ts index 261aa23cb..95258cba6 100644 --- a/src/Faction/Faction.ts +++ b/src/Faction/Faction.ts @@ -1,6 +1,6 @@ import { FactionInfo, FactionInfos } from "./FactionInfo"; import { favorToRep, repToFavor } from "./formulas/favor"; -import { Generic_fromJSON, Generic_toJSON, Reviver } from "../utils/JSONReviver"; +import { Generic_fromJSON, Generic_toJSON, IReviverValue, Reviver } from "../utils/JSONReviver"; export class Faction { /** @@ -75,15 +75,14 @@ export class Faction { /** * Serialize the current object to a JSON save state. */ - toJSON(): any { + toJSON(): IReviverValue { return Generic_toJSON("Faction", this); } /** * Initiatizes a Faction object from a JSON save state. */ - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types - static fromJSON(value: any): Faction { + static fromJSON(value: IReviverValue): Faction { return Generic_fromJSON(Faction, value.data); } } diff --git a/src/Gang/Gang.ts b/src/Gang/Gang.ts index 81e337e94..ecca414f5 100644 --- a/src/Gang/Gang.ts +++ b/src/Gang/Gang.ts @@ -8,7 +8,7 @@ import { Faction } from "../Faction/Faction"; import { Factions } from "../Faction/Factions"; import { dialogBoxCreate } from "../ui/React/DialogBox"; -import { Reviver, Generic_toJSON, Generic_fromJSON } from "../utils/JSONReviver"; +import { Reviver, Generic_toJSON, Generic_fromJSON, IReviverValue } from "../utils/JSONReviver"; import { exceptionAlert } from "../utils/helpers/exceptionAlert"; import { getRandomInt } from "../utils/helpers/getRandomInt"; @@ -399,15 +399,14 @@ export class Gang implements IGang { /** * Serialize the current object to a JSON save state. */ - toJSON(): any { + toJSON(): IReviverValue { return Generic_toJSON("Gang", this); } /** * Initiatizes a Gang object from a JSON save state. */ - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types - static fromJSON(value: any): Gang { + static fromJSON(value: IReviverValue): Gang { return Generic_fromJSON(Gang, value.data); } } diff --git a/src/Gang/GangMember.ts b/src/Gang/GangMember.ts index 87ba39c0b..be97a58cb 100644 --- a/src/Gang/GangMember.ts +++ b/src/Gang/GangMember.ts @@ -5,7 +5,7 @@ import { GangMemberUpgrades } from "./GangMemberUpgrades"; import { IAscensionResult } from "./IAscensionResult"; import { IPlayer } from "../PersonObjects/IPlayer"; import { IGang } from "./IGang"; -import { Generic_fromJSON, Generic_toJSON, Reviver } from "../utils/JSONReviver"; +import { Generic_fromJSON, Generic_toJSON, IReviverValue, Reviver } from "../utils/JSONReviver"; import { calculateRespectGain, calculateMoneyGain, @@ -320,15 +320,14 @@ export class GangMember { /** * Serialize the current object to a JSON save state. */ - toJSON(): any { + toJSON(): IReviverValue { return Generic_toJSON("GangMember", this); } /** * Initiatizes a GangMember object from a JSON save state. */ - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types - static fromJSON(value: any): GangMember { + static fromJSON(value: IReviverValue): GangMember { return Generic_fromJSON(GangMember, value.data); } } diff --git a/src/Gang/IGang.ts b/src/Gang/IGang.ts index 827be1914..6d6400a19 100644 --- a/src/Gang/IGang.ts +++ b/src/Gang/IGang.ts @@ -3,6 +3,7 @@ import { GangMember } from "./GangMember"; import { WorkerScript } from "../Netscript/WorkerScript"; import { IPlayer } from "../PersonObjects/IPlayer"; import { IAscensionResult } from "./IAscensionResult"; +import { IReviverValue } from "src/utils/JSONReviver"; export interface IGang { facName: string; @@ -42,5 +43,5 @@ export interface IGang { getDiscount(): number; getAllTaskNames(): string[]; getUpgradeCost(upg: GangMemberUpgrade): number; - toJSON(): any; + toJSON(): IReviverValue; } diff --git a/src/Hacknet/HacknetNode.ts b/src/Hacknet/HacknetNode.ts index e9a8e955a..4ba906f3e 100644 --- a/src/Hacknet/HacknetNode.ts +++ b/src/Hacknet/HacknetNode.ts @@ -17,7 +17,7 @@ import { import { HacknetNodeConstants } from "./data/Constants"; import { dialogBoxCreate } from "../ui/React/DialogBox"; -import { Generic_fromJSON, Generic_toJSON, Reviver } from "../utils/JSONReviver"; +import { Generic_fromJSON, Generic_toJSON, IReviverValue, Reviver } from "../utils/JSONReviver"; import { ObjectValidator, minMax } from "../utils/Validator"; export class HacknetNode implements IHacknetNode { @@ -123,15 +123,14 @@ export class HacknetNode implements IHacknetNode { /** * Serialize the current object to a JSON save state. */ - toJSON(): any { + toJSON(): IReviverValue { return Generic_toJSON("HacknetNode", this); } /** * Initiatizes a HacknetNode object from a JSON save state. */ - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types - static fromJSON(value: any): HacknetNode { + static fromJSON(value: IReviverValue): HacknetNode { return Generic_fromJSON(HacknetNode, value.data); } } diff --git a/src/Hacknet/HacknetServer.ts b/src/Hacknet/HacknetServer.ts index 69828c254..1de09e52d 100644 --- a/src/Hacknet/HacknetServer.ts +++ b/src/Hacknet/HacknetServer.ts @@ -18,7 +18,7 @@ import { import { createRandomIp } from "../utils/IPAddress"; -import { Generic_fromJSON, Generic_toJSON, Reviver } from "../utils/JSONReviver"; +import { Generic_fromJSON, Generic_toJSON, IReviverValue, Reviver } from "../utils/JSONReviver"; import { IPlayer } from "../PersonObjects/IPlayer"; interface IConstructorParams { @@ -145,13 +145,12 @@ export class HacknetServer extends BaseServer implements IHacknetNode { } // Serialize the current object to a JSON save state - toJSON(): any { + toJSON(): IReviverValue { return Generic_toJSON("HacknetServer", this); } // Initializes a HacknetServer Object from a JSON save state - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types - static fromJSON(value: any): HacknetServer { + static fromJSON(value: IReviverValue): HacknetServer { return Generic_fromJSON(HacknetServer, value.data); } } diff --git a/src/Hacknet/HashManager.ts b/src/Hacknet/HashManager.ts index d07840e81..45560d08b 100644 --- a/src/Hacknet/HashManager.ts +++ b/src/Hacknet/HashManager.ts @@ -10,7 +10,7 @@ import { HashUpgrades } from "./HashUpgrades"; import { HashUpgrade } from "./HashUpgrade"; import { IMap } from "../types"; -import { Generic_fromJSON, Generic_toJSON, Reviver } from "../utils/JSONReviver"; +import { Generic_fromJSON, Generic_toJSON, IReviverValue, Reviver } from "../utils/JSONReviver"; export class HashManager { // Max number of hashes this can hold. Equal to the sum of capacities of @@ -157,13 +157,12 @@ export class HashManager { } //Serialize the current object to a JSON save state. - toJSON(): any { + toJSON(): IReviverValue { return Generic_toJSON("HashManager", this); } // Initiatizes a HashManager object from a JSON save state. - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types - static fromJSON(value: any): HashManager { + static fromJSON(value: IReviverValue): HashManager { return Generic_fromJSON(HashManager, value.data); } } diff --git a/src/PersonObjects/Player/PlayerObject.ts b/src/PersonObjects/Player/PlayerObject.ts index 9e00c8bf4..6fda7650d 100644 --- a/src/PersonObjects/Player/PlayerObject.ts +++ b/src/PersonObjects/Player/PlayerObject.ts @@ -31,7 +31,7 @@ import { HashManager } from "../../Hacknet/HashManager"; import { CityName } from "../../Locations/data/CityNames"; import { MoneySourceTracker } from "../../utils/MoneySourceTracker"; -import { Reviver, Generic_toJSON, Generic_fromJSON } from "../../utils/JSONReviver"; +import { Reviver, Generic_toJSON, Generic_fromJSON, IReviverValue } from "../../utils/JSONReviver"; import { ISkillProgress } from "../formulas/skill"; import { PlayerAchievement } from "../../Achievements/Achievements"; import { cyrb53 } from "../../utils/StringHelperFunctions"; @@ -420,15 +420,14 @@ export class PlayerObject implements IPlayer { /** * Serialize the current object to a JSON save state. */ - toJSON(): any { + toJSON(): IReviverValue { return Generic_toJSON("PlayerObject", this); } /** * Initiatizes a PlayerObject object from a JSON save state. */ - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types - static fromJSON(value: any): PlayerObject { + static fromJSON(value: IReviverValue): PlayerObject { return Generic_fromJSON(PlayerObject, value.data); } } diff --git a/src/PersonObjects/Sleeve/Sleeve.ts b/src/PersonObjects/Sleeve/Sleeve.ts index dd48c3b2a..fbe6757b1 100644 --- a/src/PersonObjects/Sleeve/Sleeve.ts +++ b/src/PersonObjects/Sleeve/Sleeve.ts @@ -32,7 +32,7 @@ import { Factions } from "../../Faction/Factions"; import { CityName } from "../../Locations/data/CityNames"; import { LocationName } from "../../Locations/data/LocationNames"; -import { Generic_fromJSON, Generic_toJSON, Reviver } from "../../utils/JSONReviver"; +import { Generic_fromJSON, Generic_toJSON, IReviverValue, Reviver } from "../../utils/JSONReviver"; import { BladeburnerConstants } from "../../Bladeburner/data/Constants"; import { numeralWrapper } from "../../ui/numeralFormat"; import { capitalizeFirstLetter, capitalizeEachWord } from "../../utils/StringHelperFunctions"; @@ -1236,15 +1236,14 @@ export class Sleeve extends Person { /** * Serialize the current object to a JSON save state. */ - toJSON(): any { + toJSON(): IReviverValue { return Generic_toJSON("Sleeve", this); } /** * Initiatizes a Sleeve object from a JSON save state. */ - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types - static fromJSON(value: any): Sleeve { + static fromJSON(value: IReviverValue): Sleeve { return Generic_fromJSON(Sleeve, value.data); } } diff --git a/src/SaveObject.tsx b/src/SaveObject.tsx index 22b9c206f..dbd5024e0 100755 --- a/src/SaveObject.tsx +++ b/src/SaveObject.tsx @@ -21,7 +21,7 @@ import { SnackbarEvents, ToastVariant } from "./ui/React/Snackbar"; import * as ExportBonus from "./ExportBonus"; import { dialogBoxCreate } from "./ui/React/DialogBox"; -import { Reviver, Generic_toJSON, Generic_fromJSON } from "./utils/JSONReviver"; +import { Reviver, Generic_toJSON, Generic_fromJSON, IReviverValue } from "./utils/JSONReviver"; import { save } from "./db"; import { v1APIBreak } from "./utils/v1APIBreak"; import { AugmentationNames } from "./Augmentation/data/AugmentationNames"; @@ -234,11 +234,11 @@ class BitburnerSaveObject { return Promise.resolve(data); } - toJSON(): any { + toJSON(): IReviverValue { return Generic_toJSON("BitburnerSaveObject", this); } - static fromJSON(value: { data: any }): BitburnerSaveObject { + static fromJSON(value: IReviverValue): BitburnerSaveObject { return Generic_fromJSON(BitburnerSaveObject, value.data); } } diff --git a/src/Script/RunningScript.ts b/src/Script/RunningScript.ts index 0f9b2b3bb..2ab10298b 100644 --- a/src/Script/RunningScript.ts +++ b/src/Script/RunningScript.ts @@ -8,7 +8,7 @@ import { Settings } from "../Settings/Settings"; import { IMap } from "../types"; import { Terminal } from "../Terminal"; -import { Generic_fromJSON, Generic_toJSON, Reviver } from "../utils/JSONReviver"; +import { Generic_fromJSON, Generic_toJSON, IReviverValue, Reviver } from "../utils/JSONReviver"; import { formatTime } from "../utils/helpers/formatTime"; export class RunningScript { @@ -123,13 +123,12 @@ export class RunningScript { } // Serialize the current object to a JSON save state - toJSON(): any { + toJSON(): IReviverValue { return Generic_toJSON("RunningScript", this); } // Initializes a RunningScript Object from a JSON save state - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types - static fromJSON(value: any): RunningScript { + static fromJSON(value: IReviverValue): RunningScript { return Generic_fromJSON(RunningScript, value.data); } } diff --git a/src/Script/Script.ts b/src/Script/Script.ts index 458b40c3f..70f6a72f6 100644 --- a/src/Script/Script.ts +++ b/src/Script/Script.ts @@ -7,7 +7,7 @@ import { calculateRamUsage, RamUsageEntry } from "./RamCalculations"; import { ScriptUrl } from "./ScriptUrl"; -import { Generic_fromJSON, Generic_toJSON, Reviver } from "../utils/JSONReviver"; +import { Generic_fromJSON, Generic_toJSON, IReviverValue, Reviver } from "../utils/JSONReviver"; import { roundToTwo } from "../utils/helpers/roundToTwo"; import { IPlayer } from "../PersonObjects/IPlayer"; @@ -133,13 +133,12 @@ export class Script { } // Serialize the current object to a JSON save state - toJSON(): any { + toJSON(): IReviverValue { return Generic_toJSON("Script", this); } // Initializes a Script Object from a JSON save state - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types - static fromJSON(value: any): Script { + static fromJSON(value: IReviverValue): Script { const s = Generic_fromJSON(Script, value.data); // Force the url to blank from the save data. Urls are not valid outside the current browser page load. s.url = ""; diff --git a/src/Server/Server.ts b/src/Server/Server.ts index 076f13926..442b6d461 100644 --- a/src/Server/Server.ts +++ b/src/Server/Server.ts @@ -5,7 +5,7 @@ import { BitNodeMultipliers } from "../BitNode/BitNodeMultipliers"; import { createRandomString } from "../utils/helpers/createRandomString"; import { createRandomIp } from "../utils/IPAddress"; -import { Generic_fromJSON, Generic_toJSON, Reviver } from "../utils/JSONReviver"; +import { Generic_fromJSON, Generic_toJSON, IReviverValue, Reviver } from "../utils/JSONReviver"; export interface IConstructorParams { adminRights?: boolean; @@ -152,13 +152,12 @@ export class Server extends BaseServer { /** * Serialize the current object to a JSON save state */ - toJSON(): any { + toJSON(): IReviverValue { return Generic_toJSON("Server", this); } // Initializes a Server Object from a JSON save state - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types - static fromJSON(value: any): Server { + static fromJSON(value: IReviverValue): Server { return Generic_fromJSON(Server, value.data); } } diff --git a/src/StockMarket/Order.ts b/src/StockMarket/Order.ts index b55d45e5b..d37092116 100644 --- a/src/StockMarket/Order.ts +++ b/src/StockMarket/Order.ts @@ -5,7 +5,7 @@ import { OrderTypes } from "./data/OrderTypes"; import { PositionTypes } from "./data/PositionTypes"; -import { Generic_fromJSON, Generic_toJSON, Reviver } from "../utils/JSONReviver"; +import { Generic_fromJSON, Generic_toJSON, IReviverValue, Reviver } from "../utils/JSONReviver"; export class Order { readonly pos: PositionTypes; @@ -46,15 +46,14 @@ export class Order { /** * Serialize the Order to a JSON save state. */ - toJSON(): any { + toJSON(): IReviverValue { return Generic_toJSON("Order", this); } /** * Initializes a Order from a JSON save state */ - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types - static fromJSON(value: any): Order { + static fromJSON(value: IReviverValue): Order { return Generic_fromJSON(Order, value.data); } } diff --git a/src/StockMarket/Stock.ts b/src/StockMarket/Stock.ts index f6e27db31..012da4eda 100644 --- a/src/StockMarket/Stock.ts +++ b/src/StockMarket/Stock.ts @@ -1,5 +1,5 @@ import { IMinMaxRange } from "../types"; -import { Generic_fromJSON, Generic_toJSON, Reviver } from "../utils/JSONReviver"; +import { Generic_fromJSON, Generic_toJSON, IReviverValue, Reviver } from "../utils/JSONReviver"; import { getRandomInt } from "../utils/helpers/getRandomInt"; export const StockForecastInfluenceLimit = 5; @@ -36,7 +36,7 @@ function toNumber(n: number | IMinMaxRange): number { return n; } case "object": { - const range = n ; + const range = n; value = getRandomInt(range.min, range.max); break; } @@ -308,15 +308,14 @@ export class Stock { /** * Serialize the Stock to a JSON save state. */ - toJSON(): any { + toJSON(): IReviverValue { return Generic_toJSON("Stock", this); } /** * Initializes a Stock from a JSON save state */ - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types - static fromJSON(value: any): Stock { + static fromJSON(value: IReviverValue): Stock { return Generic_fromJSON(Stock, value.data); } } diff --git a/src/TextFile.ts b/src/TextFile.ts index 8ee024795..64594a158 100644 --- a/src/TextFile.ts +++ b/src/TextFile.ts @@ -1,6 +1,6 @@ import { dialogBoxCreate } from "./ui/React/DialogBox"; import { BaseServer } from "./Server/BaseServer"; -import { Generic_fromJSON, Generic_toJSON, Reviver } from "./utils/JSONReviver"; +import { Generic_fromJSON, Generic_toJSON, IReviverValue, Reviver } from "./utils/JSONReviver"; import { removeLeadingSlash, isInRootDirectory } from "./Terminal/DirectoryHelpers"; /** @@ -86,7 +86,7 @@ export class TextFile { /** * Serialize the current file to a JSON save state. */ - toJSON(): any { + toJSON(): IReviverValue { return Generic_toJSON("TextFile", this); } @@ -100,8 +100,7 @@ export class TextFile { /** * Initiatizes a TextFile from a JSON save state. */ - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types - static fromJSON(value: any): TextFile { + static fromJSON(value: IReviverValue): TextFile { return Generic_fromJSON(TextFile, value.data); } } @@ -121,7 +120,7 @@ export function getTextFile(fn: string, server: BaseServer): TextFile | null { filename = removeLeadingSlash(filename); } - for (const file of server.textFiles ) { + for (const file of server.textFiles) { if (file.fn === filename) { return file; } diff --git a/src/utils/MoneySourceTracker.ts b/src/utils/MoneySourceTracker.ts index 5aeef5d2f..93aa0256d 100644 --- a/src/utils/MoneySourceTracker.ts +++ b/src/utils/MoneySourceTracker.ts @@ -50,12 +50,11 @@ export class MoneySourceTracker { } // Serialize the current object to a JSON save state. - toJSON(): any { + toJSON(): IReviverValue { return Generic_toJSON("MoneySourceTracker", this); } // Initiatizes a MoneySourceTracker object from a JSON save state. - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types static fromJSON(value: IReviverValue): MoneySourceTracker { return Generic_fromJSON(MoneySourceTracker, value.data); }