Skip to content

Commit

Permalink
refactor: fix type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
uhyo committed Jul 6, 2022
1 parent b36ebad commit 6adbf4b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
13 changes: 6 additions & 7 deletions src/builder/composers/StateLocationComposer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export class StateLocationComposer<
Key extends string,
StateValue,
IsOptional extends boolean
> implements LocationComposer<OptionalIf<IsOptional, StateValue>> {
> implements LocationComposer<OptionalIf<IsOptional, StateValue>>
{
readonly key: Key;
readonly optional: IsOptional;
readonly validator: Validator<OptionalIf<IsOptional, StateValue>>;
Expand All @@ -32,11 +33,10 @@ export class StateLocationComposer<
base: Readonly<Location<S>>,
segment: OptionalIf<IsOptional, StateValue>
): Location<S> {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const newState = {
...base.state,
...(base.state as {}),
[this.key]: segment,
};
} as S;

return {
...base,
Expand Down Expand Up @@ -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<string, unknown>;
const nextLocation = {
...location,
state: rest,
state: rest as Omit<S, Key>,
};
return [
{
Expand Down
4 changes: 3 additions & 1 deletion src/util/path/locationDiff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ export function locationDiff<

const diffState: Record<string, unknown> = {};
const baseState = (base.state ?? {}) as Record<string, unknown>;
for (const [key, value] of Object.entries(location.state ?? {})) {
for (const [key, value] of Object.entries(
(location.state ?? {}) as Record<string, unknown>
)) {
if (baseState[key] !== undefined) {
if (baseState[key] !== value) {
return undefined;
Expand Down

0 comments on commit 6adbf4b

Please sign in to comment.