From 6adbf4b1980e40add2012e2ba7e1615ccfb9d314 Mon Sep 17 00:00:00 2001 From: uhyo Date: Wed, 6 Jul 2022 21:19:30 +0900 Subject: [PATCH] refactor: fix type errors --- .../composers/StateLocationComposer/index.ts | 13 ++++++------- src/util/path/locationDiff.ts | 4 +++- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/builder/composers/StateLocationComposer/index.ts b/src/builder/composers/StateLocationComposer/index.ts index d0830ef..18dbba9 100644 --- a/src/builder/composers/StateLocationComposer/index.ts +++ b/src/builder/composers/StateLocationComposer/index.ts @@ -10,7 +10,8 @@ export class StateLocationComposer< Key extends string, StateValue, IsOptional extends boolean -> implements LocationComposer> { +> implements LocationComposer> +{ readonly key: Key; readonly optional: IsOptional; readonly validator: Validator>; @@ -32,11 +33,10 @@ export class StateLocationComposer< base: Readonly>, segment: OptionalIf ): Location { - // eslint-disable-next-line @typescript-eslint/no-explicit-any const newState = { - ...base.state, + ...(base.state as {}), [this.key]: segment, - }; + } as S; return { ...base, @@ -66,11 +66,10 @@ export class StateLocationComposer< return []; } - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const { [this.key]: _, ...rest } = state; + const { [this.key]: _, ...rest } = state as Record; const nextLocation = { ...location, - state: rest, + state: rest as Omit, }; return [ { diff --git a/src/util/path/locationDiff.ts b/src/util/path/locationDiff.ts index 8385da4..3e4e429 100644 --- a/src/util/path/locationDiff.ts +++ b/src/util/path/locationDiff.ts @@ -48,7 +48,9 @@ export function locationDiff< const diffState: Record = {}; const baseState = (base.state ?? {}) as Record; - for (const [key, value] of Object.entries(location.state ?? {})) { + for (const [key, value] of Object.entries( + (location.state ?? {}) as Record + )) { if (baseState[key] !== undefined) { if (baseState[key] !== value) { return undefined;