From 83979c4703a755168f752ac844c7e1e896ae5344 Mon Sep 17 00:00:00 2001 From: sinclair Date: Sun, 17 Nov 2024 05:44:48 +0900 Subject: [PATCH] Revert Never Assertion on Definition Key Indexer --- src/compiler/compiler.ts | 2 +- src/errors/errors.ts | 2 +- src/value/cast/cast.ts | 2 +- src/value/check/check.ts | 2 +- src/value/clean/clean.ts | 2 +- src/value/convert/convert.ts | 2 +- src/value/create/create.ts | 2 +- src/value/default/default.ts | 2 +- src/value/transform/decode.ts | 2 +- src/value/transform/encode.ts | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/compiler/compiler.ts b/src/compiler/compiler.ts index 01ab4dcf..6e438702 100644 --- a/src/compiler/compiler.ts +++ b/src/compiler/compiler.ts @@ -291,7 +291,7 @@ export namespace TypeCompiler { } function* FromImport(schema: TImport, references: TSchema[], value: string): IterableIterator { const definitions = globalThis.Object.values(schema.$defs) as TSchema[] - const target = schema.$defs[schema.$ref as never] as TSchema + const target = schema.$defs[schema.$ref] as TSchema yield* Visit(target, [...references, ...definitions], value) } function* FromInteger(schema: TInteger, references: TSchema[], value: string): IterableIterator { diff --git a/src/errors/errors.ts b/src/errors/errors.ts index b7ac37f4..9bb1f6cd 100644 --- a/src/errors/errors.ts +++ b/src/errors/errors.ts @@ -305,7 +305,7 @@ function* FromFunction(schema: TFunction, references: TSchema[], path: string, v } function* FromImport(schema: TImport, references: TSchema[], path: string, value: any): IterableIterator { const definitions = globalThis.Object.values(schema.$defs) as TSchema[] - const target = schema.$defs[schema.$ref as never] as TSchema + const target = schema.$defs[schema.$ref] as TSchema yield* Visit(target, [...references, ...definitions], path, value) } function* FromInteger(schema: TInteger, references: TSchema[], path: string, value: any): IterableIterator { diff --git a/src/value/cast/cast.ts b/src/value/cast/cast.ts index bdcb7b8c..a6f9d989 100644 --- a/src/value/cast/cast.ts +++ b/src/value/cast/cast.ts @@ -136,7 +136,7 @@ function FromConstructor(schema: TConstructor, references: TSchema[], value: any } function FromImport(schema: TImport, references: TSchema[], value: unknown): boolean { const definitions = globalThis.Object.values(schema.$defs) as TSchema[] - const target = schema.$defs[schema.$ref as never] as TSchema + const target = schema.$defs[schema.$ref] as TSchema return Visit(target, [...references, ...definitions], value) } function FromIntersect(schema: TIntersect, references: TSchema[], value: any): any { diff --git a/src/value/check/check.ts b/src/value/check/check.ts index 7ac4e1e8..c5244e22 100644 --- a/src/value/check/check.ts +++ b/src/value/check/check.ts @@ -188,7 +188,7 @@ function FromFunction(schema: TFunction, references: TSchema[], value: any): boo } function FromImport(schema: TImport, references: TSchema[], value: any): boolean { const definitions = globalThis.Object.values(schema.$defs) as TSchema[] - const target = schema.$defs[schema.$ref as never] as TSchema + const target = schema.$defs[schema.$ref] as TSchema return Visit(target, [...references, ...definitions], value) } function FromInteger(schema: TInteger, references: TSchema[], value: any): boolean { diff --git a/src/value/clean/clean.ts b/src/value/clean/clean.ts index 1e7df9f3..341cf025 100644 --- a/src/value/clean/clean.ts +++ b/src/value/clean/clean.ts @@ -77,7 +77,7 @@ function FromArray(schema: TArray, references: TSchema[], value: unknown): any { } function FromImport(schema: TImport, references: TSchema[], value: unknown): any { const definitions = globalThis.Object.values(schema.$defs) as TSchema[] - const target = schema.$defs[schema.$ref as never] as TSchema + const target = schema.$defs[schema.$ref] as TSchema return Visit(target, [...references, ...definitions], value) } function FromIntersect(schema: TIntersect, references: TSchema[], value: unknown): any { diff --git a/src/value/convert/convert.ts b/src/value/convert/convert.ts index bacae2ba..1cfaa108 100644 --- a/src/value/convert/convert.ts +++ b/src/value/convert/convert.ts @@ -185,7 +185,7 @@ function FromDate(schema: TDate, references: TSchema[], value: any): unknown { } function FromImport(schema: TImport, references: TSchema[], value: unknown): unknown { const definitions = globalThis.Object.values(schema.$defs) as TSchema[] - const target = schema.$defs[schema.$ref as never] as TSchema + const target = schema.$defs[schema.$ref] as TSchema return Visit(target, [...references, ...definitions], value) } function FromInteger(schema: TInteger, references: TSchema[], value: any): unknown { diff --git a/src/value/create/create.ts b/src/value/create/create.ts index 00a0c0c1..478aab13 100644 --- a/src/value/create/create.ts +++ b/src/value/create/create.ts @@ -170,7 +170,7 @@ function FromFunction(schema: TFunction, references: TSchema[]): any { } function FromImport(schema: TImport, references: TSchema[]): any { const definitions = globalThis.Object.values(schema.$defs) as TSchema[] - const target = schema.$defs[schema.$ref as never] as TSchema + const target = schema.$defs[schema.$ref] as TSchema return Visit(target, [...references, ...definitions]) } function FromInteger(schema: TInteger, references: TSchema[]): any { diff --git a/src/value/default/default.ts b/src/value/default/default.ts index 3e379047..30ddbc95 100644 --- a/src/value/default/default.ts +++ b/src/value/default/default.ts @@ -81,7 +81,7 @@ function FromDate(schema: TArray, references: TSchema[], value: unknown): any { } function FromImport(schema: TImport, references: TSchema[], value: unknown): any { const definitions = globalThis.Object.values(schema.$defs) as TSchema[] - const target = schema.$defs[schema.$ref as never] as TSchema + const target = schema.$defs[schema.$ref] as TSchema return Visit(target, [...references, ...definitions], value) } function FromIntersect(schema: TIntersect, references: TSchema[], value: unknown): any { diff --git a/src/value/transform/decode.ts b/src/value/transform/decode.ts index 8bb957b0..013b0abd 100644 --- a/src/value/transform/decode.ts +++ b/src/value/transform/decode.ts @@ -119,7 +119,7 @@ function FromIntersect(schema: TIntersect, references: TSchema[], path: string, // prettier-ignore function FromImport(schema: TImport, references: TSchema[], path: string, value: unknown): unknown { const definitions = globalThis.Object.values(schema.$defs) as TSchema[] - const target = schema.$defs[schema.$ref as never] as TSchema + const target = schema.$defs[schema.$ref] as TSchema const transform = schema[TransformKind as never] // Note: we need to re-spec the target as TSchema + [TransformKind] const transformTarget = { [TransformKind]: transform, ...target } as TSchema diff --git a/src/value/transform/encode.ts b/src/value/transform/encode.ts index 3be3ba67..3ac8c54c 100644 --- a/src/value/transform/encode.ts +++ b/src/value/transform/encode.ts @@ -99,7 +99,7 @@ function FromArray(schema: TArray, references: TSchema[], path: string, value: a // prettier-ignore function FromImport(schema: TImport, references: TSchema[], path: string, value: unknown): unknown { const definitions = globalThis.Object.values(schema.$defs) as TSchema[] - const target = schema.$defs[schema.$ref as never] as TSchema + const target = schema.$defs[schema.$ref] as TSchema const transform = schema[TransformKind as never] // Note: we need to re-spec the target as TSchema + [TransformKind] const transformTarget = { [TransformKind]: transform, ...target } as TSchema