From 2b72077af4fc06b7d49f01e71baeb7f69695695e Mon Sep 17 00:00:00 2001 From: Bertie690 <136088738+Bertie690@users.noreply.github.com> Date: Mon, 4 Aug 2025 13:16:19 -0400 Subject: [PATCH] Maybe fixed typecheck error 0.5 --- src/data/positional-tags/load-positional-tag.ts | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/data/positional-tags/load-positional-tag.ts b/src/data/positional-tags/load-positional-tag.ts index eb79f04baf5..ebf079a916e 100644 --- a/src/data/positional-tags/load-positional-tag.ts +++ b/src/data/positional-tags/load-positional-tag.ts @@ -25,19 +25,15 @@ export function loadPositionalTag({ * This function does not perform any checking if the added tag is valid. */ export function loadPositionalTag(tag: SerializedPositionalTag): PositionalTag; -export function loadPositionalTag(tag: serializedPosTagMap[T]): posTagInstanceMap[T] { +export function loadPositionalTag(tag: SerializedPositionalTag): PositionalTag { // Update the global arena flyout - globalScene.arena.eventTarget.dispatchEvent(new PositionalTagAddedEvent(tag)); + // Create the new tag + // TODO: review how many type assertions we need here const { tagType, ...rest } = tag; - // Note: We need 2 type assertions here: - // 1 because TS doesn't narrow the type of TagClass correctly based on `T`. - // It converts it into `new (DelayedAttackTag | WishTag) => DelayedAttackTag & WishTag` - const tagClass = posTagConstructorMap[tagType] as new (args: posTagParamMap[T]) => posTagInstanceMap[T]; - // 2 because TS doesn't narrow the type of `rest` correctly - // (from `Omit into `posTagParamMap[T]`) - return new tagClass(rest as unknown as posTagParamMap[T]); + const tagClass = posTagConstructorMap[tagType]; + return new tagClass(rest); } /** Const object mapping tag types to their constructors. */