Resolves Type Issue in ProfileFixerService

When attempting to access a property/type that *shouldn't* exist (on purpose) it has to be cast to the type manually, else annoying type error.
This commit is contained in:
Refringe 2023-11-16 10:11:31 -05:00
parent 00be492d5e
commit be841a3de3
No known key found for this signature in database
GPG Key ID: 64E03E5F892C6F9E

View File

@ -6,6 +6,7 @@ import { ItemHelper } from "@spt-aki/helpers/ItemHelper";
import { ProfileHelper } from "@spt-aki/helpers/ProfileHelper"; import { ProfileHelper } from "@spt-aki/helpers/ProfileHelper";
import { TraderHelper } from "@spt-aki/helpers/TraderHelper"; import { TraderHelper } from "@spt-aki/helpers/TraderHelper";
import { IPmcData } from "@spt-aki/models/eft/common/IPmcData"; import { IPmcData } from "@spt-aki/models/eft/common/IPmcData";
import { IHideoutImprovement } from "@spt-aki/models/eft/common/tables/IBotBase";
import { Bonus, HideoutSlot, IQuestStatus } from "@spt-aki/models/eft/common/tables/IBotBase"; import { Bonus, HideoutSlot, IQuestStatus } from "@spt-aki/models/eft/common/tables/IBotBase";
import { IPmcDataRepeatableQuest, IRepeatableQuest } from "@spt-aki/models/eft/common/tables/IRepeatableQuests"; import { IPmcDataRepeatableQuest, IRepeatableQuest } from "@spt-aki/models/eft/common/tables/IRepeatableQuests";
import { StageBonus } from "@spt-aki/models/eft/hideout/IHideoutArea"; import { StageBonus } from "@spt-aki/models/eft/hideout/IHideoutArea";
@ -1145,10 +1146,10 @@ export class ProfileFixerService
*/ */
protected migrateImprovements(pmcProfile: IPmcData): void protected migrateImprovements(pmcProfile: IPmcData): void
{ {
if (pmcProfile.Hideout.Improvements) if ("Improvements" in pmcProfile.Hideout)
{ {
// Correct name is `Improvement` const improvements = pmcProfile.Hideout.Improvements as Record<string, IHideoutImprovement>;
pmcProfile.Hideout.Improvement = this.jsonUtil.clone(pmcProfile.Hideout.Improvements); pmcProfile.Hideout.Improvement = this.jsonUtil.clone(improvements);
delete pmcProfile.Hideout.Improvements; delete pmcProfile.Hideout.Improvements;
this.logger.success("Successfully migrated hideout Improvements data to new location, deleted old data"); this.logger.success("Successfully migrated hideout Improvements data to new location, deleted old data");
} }