From c7321537e20857fa079ec3a1b7d988540e58fb97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Costa?= Date: Sun, 13 Oct 2024 20:13:10 -0700 Subject: [PATCH] Remove UnknownIfNever --- packages/all/src/index.ts | 15 +++----------- packages/arktype/src/index.ts | 15 +++----------- packages/arktype/src/resolver.ts | 6 ++++-- packages/class-validator/src/index.ts | 15 +++----------- packages/class-validator/src/resolver.ts | 8 ++++---- packages/core/src/index.ts | 8 +------- packages/core/src/resolver.ts | 20 +++++++------------ packages/core/src/utils.ts | 7 ++++--- packages/core/src/validation.ts | 9 +++------ packages/core/src/wrap.ts | 6 +----- packages/deepkit/src/index.ts | 15 +++----------- packages/deepkit/src/resolver.ts | 4 ++-- packages/effect/src/index.ts | 15 +++----------- packages/effect/src/resolver.ts | 4 ++-- packages/fastest-validator/src/index.ts | 15 +++----------- packages/fastest-validator/src/resolver.ts | 4 ++-- packages/function/src/index.ts | 15 +++----------- packages/function/src/resolver.ts | 8 ++++---- packages/io-ts/src/index.ts | 15 +++----------- packages/io-ts/src/resolver.ts | 8 ++++++-- packages/joi/src/index.ts | 15 +++----------- packages/joi/src/resolver.ts | 4 ++-- packages/json/src/index.ts | 15 +++----------- packages/json/src/resolver.ts | 4 ++-- packages/main/src/index.ts | 15 +++----------- packages/ow/src/index.ts | 15 +++----------- packages/ow/src/resolver.ts | 4 ++-- packages/runtypes/src/index.ts | 15 +++----------- packages/runtypes/src/resolver.ts | 6 ++++-- packages/superstruct/src/index.ts | 15 +++----------- packages/superstruct/src/resolver.ts | 4 ++-- packages/suretype/src/index.ts | 15 +++----------- packages/suretype/src/resolver.ts | 6 ++++-- packages/typebox/src/index.ts | 15 +++----------- packages/typebox/src/resolver.ts | 6 ++++-- packages/valibot/src/index.ts | 15 +++----------- packages/valibot/src/resolver.ts | 4 ++-- packages/valita/src/index.ts | 15 +++----------- packages/valita/src/resolver.ts | 4 ++-- packages/vine/src/index.ts | 15 +++----------- packages/vine/src/resolver.ts | 4 ++-- packages/yup/src/index.ts | 15 +++----------- packages/yup/src/resolver.ts | 4 ++-- packages/zod/src/index.ts | 15 +++----------- packages/zod/src/resolver.ts | 6 ++++-- turbo/generators/config.ts | 5 +---- .../templates/adapter/src/index.ts.hbs | 15 +++----------- .../create-adapter/src/resolver.ts.hbs | 4 ++-- 48 files changed, 141 insertions(+), 346 deletions(-) diff --git a/packages/all/src/index.ts b/packages/all/src/index.ts index 9a0904c4..4e4ecf66 100644 --- a/packages/all/src/index.ts +++ b/packages/all/src/index.ts @@ -2,12 +2,7 @@ * This file is generated. Do not modify it manually! */ -import type { - InputFrom, - OutputFrom, - SchemaFrom, - UnknownIfNever, -} from '@typeschema/core'; +import type {InputFrom, OutputFrom, SchemaFrom} from '@typeschema/core'; import { createAssert, @@ -21,12 +16,8 @@ import {validationAdapter} from './validation'; import {serializationAdapter} from './serialization'; export type Schema = SchemaFrom; -export type Infer = UnknownIfNever< - OutputFrom ->; -export type InferIn = UnknownIfNever< - InputFrom ->; +export type Infer = OutputFrom; +export type InferIn = InputFrom; export const validate = createValidate(validationAdapter); export const assert = createAssert(validate); diff --git a/packages/arktype/src/index.ts b/packages/arktype/src/index.ts index c5a15869..5a232c40 100644 --- a/packages/arktype/src/index.ts +++ b/packages/arktype/src/index.ts @@ -2,12 +2,7 @@ * This file is generated. Do not modify it manually! */ -import type { - InputFrom, - OutputFrom, - SchemaFrom, - UnknownIfNever, -} from '@typeschema/core'; +import type {InputFrom, OutputFrom, SchemaFrom} from '@typeschema/core'; import { createAssert, @@ -19,12 +14,8 @@ import {AdapterResolver} from './resolver'; import {validationAdapter} from './validation'; export type Schema = SchemaFrom; -export type Infer = UnknownIfNever< - OutputFrom ->; -export type InferIn = UnknownIfNever< - InputFrom ->; +export type Infer = OutputFrom; +export type InferIn = InputFrom; export const validate = createValidate(validationAdapter); export const assert = createAssert(validate); diff --git a/packages/arktype/src/resolver.ts b/packages/arktype/src/resolver.ts index 1399366d..fc679f0a 100644 --- a/packages/arktype/src/resolver.ts +++ b/packages/arktype/src/resolver.ts @@ -5,6 +5,8 @@ export interface AdapterResolver extends Resolver { base: IfDefined; input: this['schema'] extends this['base'] ? this['schema']['inferIn'] - : never; - output: this['schema'] extends this['base'] ? this['schema']['infer'] : never; + : unknown; + output: this['schema'] extends this['base'] + ? this['schema']['infer'] + : unknown; } diff --git a/packages/class-validator/src/index.ts b/packages/class-validator/src/index.ts index c5a15869..5a232c40 100644 --- a/packages/class-validator/src/index.ts +++ b/packages/class-validator/src/index.ts @@ -2,12 +2,7 @@ * This file is generated. Do not modify it manually! */ -import type { - InputFrom, - OutputFrom, - SchemaFrom, - UnknownIfNever, -} from '@typeschema/core'; +import type {InputFrom, OutputFrom, SchemaFrom} from '@typeschema/core'; import { createAssert, @@ -19,12 +14,8 @@ import {AdapterResolver} from './resolver'; import {validationAdapter} from './validation'; export type Schema = SchemaFrom; -export type Infer = UnknownIfNever< - OutputFrom ->; -export type InferIn = UnknownIfNever< - InputFrom ->; +export type Infer = OutputFrom; +export type InferIn = InputFrom; export const validate = createValidate(validationAdapter); export const assert = createAssert(validate); diff --git a/packages/class-validator/src/resolver.ts b/packages/class-validator/src/resolver.ts index 7250c647..36702a1a 100644 --- a/packages/class-validator/src/resolver.ts +++ b/packages/class-validator/src/resolver.ts @@ -12,11 +12,11 @@ export interface AdapterResolver extends Resolver { input: this['schema'] extends this['base'] ? this['schema'] extends {prototype: unknown} ? Attributes - : never - : never; + : unknown + : unknown; output: this['schema'] extends this['base'] ? this['schema'] extends {prototype: unknown} ? Attributes - : never - : never; + : unknown + : unknown; } diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 1ffc372a..d110d237 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -4,13 +4,7 @@ export { SerializationAdapter, ToJSONSchema, } from './serialization'; -export { - IfDefined, - memoize, - memoizeWithKey, - UnknownIfNever, - unsupportedAdapter, -} from './utils'; +export {IfDefined, memoize, memoizeWithKey, unsupportedAdapter} from './utils'; export { Assert, createAssert, diff --git a/packages/core/src/resolver.ts b/packages/core/src/resolver.ts index 42c1a943..c7059dad 100644 --- a/packages/core/src/resolver.ts +++ b/packages/core/src/resolver.ts @@ -1,5 +1,3 @@ -import type {IfDefined} from './utils'; - export interface Resolver { schema: TSchema; input: unknown; @@ -7,16 +5,12 @@ export interface Resolver { base: unknown; } -export type SchemaFrom = IfDefined< - TResolver['base'] ->; +export type SchemaFrom = TResolver['base']; -export type InputFrom = - TSchema extends SchemaFrom - ? IfDefined<(TResolver & {schema: TSchema})['input']> - : never; +export type InputFrom = (TResolver & { + schema: TSchema; +})['input']; -export type OutputFrom = - TSchema extends SchemaFrom - ? IfDefined<(TResolver & {schema: TSchema})['output']> - : never; +export type OutputFrom = (TResolver & { + schema: TSchema; +})['output']; diff --git a/packages/core/src/utils.ts b/packages/core/src/utils.ts index 87f2c41e..8c157fa0 100644 --- a/packages/core/src/utils.ts +++ b/packages/core/src/utils.ts @@ -1,13 +1,14 @@ import type {Resolver, SchemaFrom} from './resolver'; -export type IfDefined = unknown extends TValue +export type IfDefined< + TValue, + TModule extends string = '', +> = unknown extends TValue ? TModule extends '' ? never : `Cannot find module '${TModule}'` : TValue; -export type UnknownIfNever = [T] extends [never] ? unknown : T; - /* @__NO_SIDE_EFFECTS__ */ export function memoize( fn: () => Promise, diff --git a/packages/core/src/validation.ts b/packages/core/src/validation.ts index a59cfe1c..d84180e7 100644 --- a/packages/core/src/validation.ts +++ b/packages/core/src/validation.ts @@ -1,5 +1,4 @@ import type {OutputFrom, Resolver, SchemaFrom} from './resolver'; -import type {UnknownIfNever} from './utils'; import {memoizeWithKey} from './utils'; @@ -17,9 +16,7 @@ export type ValidationAdapter = < >( schema: TSchema, ) => Promise< - ( - data: unknown, - ) => Promise>>> + (data: unknown) => Promise>> >; export type Validate = < @@ -27,7 +24,7 @@ export type Validate = < >( schema: TSchema, data: unknown, -) => Promise>>>; +) => Promise>>; /* @__NO_SIDE_EFFECTS__ */ export function createValidate( @@ -47,7 +44,7 @@ export type Assert = < >( schema: TSchema, data: unknown, -) => Promise>>; +) => Promise>; /* @__NO_SIDE_EFFECTS__ */ export function createAssert( diff --git a/packages/core/src/wrap.ts b/packages/core/src/wrap.ts index 07ee32d1..806b74d3 100644 --- a/packages/core/src/wrap.ts +++ b/packages/core/src/wrap.ts @@ -1,5 +1,4 @@ import type {InputFrom, OutputFrom, Resolver, SchemaFrom} from './resolver'; -import type {UnknownIfNever} from './utils'; import type {Assert, Validate, ValidationIssue} from './validation'; export type TypeSchema = { @@ -16,10 +15,7 @@ export type Wrap = < TSchema extends SchemaFrom, >( schema: TSchema, -) => TypeSchema< - UnknownIfNever>, - UnknownIfNever> ->; +) => TypeSchema, InputFrom>; /* @__NO_SIDE_EFFECTS__ */ export function createWrap( diff --git a/packages/deepkit/src/index.ts b/packages/deepkit/src/index.ts index c5a15869..5a232c40 100644 --- a/packages/deepkit/src/index.ts +++ b/packages/deepkit/src/index.ts @@ -2,12 +2,7 @@ * This file is generated. Do not modify it manually! */ -import type { - InputFrom, - OutputFrom, - SchemaFrom, - UnknownIfNever, -} from '@typeschema/core'; +import type {InputFrom, OutputFrom, SchemaFrom} from '@typeschema/core'; import { createAssert, @@ -19,12 +14,8 @@ import {AdapterResolver} from './resolver'; import {validationAdapter} from './validation'; export type Schema = SchemaFrom; -export type Infer = UnknownIfNever< - OutputFrom ->; -export type InferIn = UnknownIfNever< - InputFrom ->; +export type Infer = OutputFrom; +export type InferIn = InputFrom; export const validate = createValidate(validationAdapter); export const assert = createAssert(validate); diff --git a/packages/deepkit/src/resolver.ts b/packages/deepkit/src/resolver.ts index 76d744a7..57f1d05e 100644 --- a/packages/deepkit/src/resolver.ts +++ b/packages/deepkit/src/resolver.ts @@ -3,6 +3,6 @@ import type {IfDefined, Resolver} from '@typeschema/core'; export interface AdapterResolver extends Resolver { base: IfDefined; - input: this['schema'] extends this['base'] ? unknown : never; - output: this['schema'] extends this['base'] ? unknown : never; + input: unknown; + output: unknown; } diff --git a/packages/effect/src/index.ts b/packages/effect/src/index.ts index 9a0904c4..4e4ecf66 100644 --- a/packages/effect/src/index.ts +++ b/packages/effect/src/index.ts @@ -2,12 +2,7 @@ * This file is generated. Do not modify it manually! */ -import type { - InputFrom, - OutputFrom, - SchemaFrom, - UnknownIfNever, -} from '@typeschema/core'; +import type {InputFrom, OutputFrom, SchemaFrom} from '@typeschema/core'; import { createAssert, @@ -21,12 +16,8 @@ import {validationAdapter} from './validation'; import {serializationAdapter} from './serialization'; export type Schema = SchemaFrom; -export type Infer = UnknownIfNever< - OutputFrom ->; -export type InferIn = UnknownIfNever< - InputFrom ->; +export type Infer = OutputFrom; +export type InferIn = InputFrom; export const validate = createValidate(validationAdapter); export const assert = createAssert(validate); diff --git a/packages/effect/src/resolver.ts b/packages/effect/src/resolver.ts index 6cf167fd..17829b72 100644 --- a/packages/effect/src/resolver.ts +++ b/packages/effect/src/resolver.ts @@ -5,8 +5,8 @@ export interface AdapterResolver extends Resolver { base: IfDefined; input: this['schema'] extends this['base'] ? Schema.Encoded - : never; + : unknown; output: this['schema'] extends this['base'] ? Schema.Type - : never; + : unknown; } diff --git a/packages/fastest-validator/src/index.ts b/packages/fastest-validator/src/index.ts index c5a15869..5a232c40 100644 --- a/packages/fastest-validator/src/index.ts +++ b/packages/fastest-validator/src/index.ts @@ -2,12 +2,7 @@ * This file is generated. Do not modify it manually! */ -import type { - InputFrom, - OutputFrom, - SchemaFrom, - UnknownIfNever, -} from '@typeschema/core'; +import type {InputFrom, OutputFrom, SchemaFrom} from '@typeschema/core'; import { createAssert, @@ -19,12 +14,8 @@ import {AdapterResolver} from './resolver'; import {validationAdapter} from './validation'; export type Schema = SchemaFrom; -export type Infer = UnknownIfNever< - OutputFrom ->; -export type InferIn = UnknownIfNever< - InputFrom ->; +export type Infer = OutputFrom; +export type InferIn = InputFrom; export const validate = createValidate(validationAdapter); export const assert = createAssert(validate); diff --git a/packages/fastest-validator/src/resolver.ts b/packages/fastest-validator/src/resolver.ts index 76a3994f..2f17b5bd 100644 --- a/packages/fastest-validator/src/resolver.ts +++ b/packages/fastest-validator/src/resolver.ts @@ -3,6 +3,6 @@ import type {ValidationSchema} from 'fastest-validator'; export interface AdapterResolver extends Resolver { base: IfDefined; - input: this['schema'] extends this['base'] ? unknown : never; - output: this['schema'] extends this['base'] ? unknown : never; + input: unknown; + output: unknown; } diff --git a/packages/function/src/index.ts b/packages/function/src/index.ts index c5a15869..5a232c40 100644 --- a/packages/function/src/index.ts +++ b/packages/function/src/index.ts @@ -2,12 +2,7 @@ * This file is generated. Do not modify it manually! */ -import type { - InputFrom, - OutputFrom, - SchemaFrom, - UnknownIfNever, -} from '@typeschema/core'; +import type {InputFrom, OutputFrom, SchemaFrom} from '@typeschema/core'; import { createAssert, @@ -19,12 +14,8 @@ import {AdapterResolver} from './resolver'; import {validationAdapter} from './validation'; export type Schema = SchemaFrom; -export type Infer = UnknownIfNever< - OutputFrom ->; -export type InferIn = UnknownIfNever< - InputFrom ->; +export type Infer = OutputFrom; +export type InferIn = InputFrom; export const validate = createValidate(validationAdapter); export const assert = createAssert(validate); diff --git a/packages/function/src/resolver.ts b/packages/function/src/resolver.ts index eba95cab..488e551c 100644 --- a/packages/function/src/resolver.ts +++ b/packages/function/src/resolver.ts @@ -8,11 +8,11 @@ export interface AdapterResolver extends Resolver { input: this['schema'] extends this['base'] ? keyof this['schema'] extends never ? Awaited> - : never - : never; + : unknown + : unknown; output: this['schema'] extends this['base'] ? keyof this['schema'] extends never ? Awaited> - : never - : never; + : unknown + : unknown; } diff --git a/packages/io-ts/src/index.ts b/packages/io-ts/src/index.ts index c5a15869..5a232c40 100644 --- a/packages/io-ts/src/index.ts +++ b/packages/io-ts/src/index.ts @@ -2,12 +2,7 @@ * This file is generated. Do not modify it manually! */ -import type { - InputFrom, - OutputFrom, - SchemaFrom, - UnknownIfNever, -} from '@typeschema/core'; +import type {InputFrom, OutputFrom, SchemaFrom} from '@typeschema/core'; import { createAssert, @@ -19,12 +14,8 @@ import {AdapterResolver} from './resolver'; import {validationAdapter} from './validation'; export type Schema = SchemaFrom; -export type Infer = UnknownIfNever< - OutputFrom ->; -export type InferIn = UnknownIfNever< - InputFrom ->; +export type Infer = OutputFrom; +export type InferIn = InputFrom; export const validate = createValidate(validationAdapter); export const assert = createAssert(validate); diff --git a/packages/io-ts/src/resolver.ts b/packages/io-ts/src/resolver.ts index c957d9ec..b0cbefd0 100644 --- a/packages/io-ts/src/resolver.ts +++ b/packages/io-ts/src/resolver.ts @@ -3,6 +3,10 @@ import type {Any, OutputOf, TypeOf} from 'io-ts'; export interface AdapterResolver extends Resolver { base: IfDefined; - input: this['schema'] extends this['base'] ? OutputOf : never; - output: this['schema'] extends this['base'] ? TypeOf : never; + input: this['schema'] extends this['base'] + ? OutputOf + : unknown; + output: this['schema'] extends this['base'] + ? TypeOf + : unknown; } diff --git a/packages/joi/src/index.ts b/packages/joi/src/index.ts index 9a0904c4..4e4ecf66 100644 --- a/packages/joi/src/index.ts +++ b/packages/joi/src/index.ts @@ -2,12 +2,7 @@ * This file is generated. Do not modify it manually! */ -import type { - InputFrom, - OutputFrom, - SchemaFrom, - UnknownIfNever, -} from '@typeschema/core'; +import type {InputFrom, OutputFrom, SchemaFrom} from '@typeschema/core'; import { createAssert, @@ -21,12 +16,8 @@ import {validationAdapter} from './validation'; import {serializationAdapter} from './serialization'; export type Schema = SchemaFrom; -export type Infer = UnknownIfNever< - OutputFrom ->; -export type InferIn = UnknownIfNever< - InputFrom ->; +export type Infer = OutputFrom; +export type InferIn = InputFrom; export const validate = createValidate(validationAdapter); export const assert = createAssert(validate); diff --git a/packages/joi/src/resolver.ts b/packages/joi/src/resolver.ts index c5ac48d3..89c5bdc7 100644 --- a/packages/joi/src/resolver.ts +++ b/packages/joi/src/resolver.ts @@ -3,6 +3,6 @@ import type {AnySchema} from 'joi'; export interface AdapterResolver extends Resolver { base: IfDefined; - input: this['schema'] extends this['base'] ? unknown : never; - output: this['schema'] extends this['base'] ? unknown : never; + input: unknown; + output: unknown; } diff --git a/packages/json/src/index.ts b/packages/json/src/index.ts index 9a0904c4..4e4ecf66 100644 --- a/packages/json/src/index.ts +++ b/packages/json/src/index.ts @@ -2,12 +2,7 @@ * This file is generated. Do not modify it manually! */ -import type { - InputFrom, - OutputFrom, - SchemaFrom, - UnknownIfNever, -} from '@typeschema/core'; +import type {InputFrom, OutputFrom, SchemaFrom} from '@typeschema/core'; import { createAssert, @@ -21,12 +16,8 @@ import {validationAdapter} from './validation'; import {serializationAdapter} from './serialization'; export type Schema = SchemaFrom; -export type Infer = UnknownIfNever< - OutputFrom ->; -export type InferIn = UnknownIfNever< - InputFrom ->; +export type Infer = OutputFrom; +export type InferIn = InputFrom; export const validate = createValidate(validationAdapter); export const assert = createAssert(validate); diff --git a/packages/json/src/resolver.ts b/packages/json/src/resolver.ts index 92e78284..daf8bf5c 100644 --- a/packages/json/src/resolver.ts +++ b/packages/json/src/resolver.ts @@ -6,8 +6,8 @@ export interface AdapterResolver extends Resolver { base: IfDefined; input: this['schema'] extends this['base'] ? IfDefined, 'json-schema-to-ts'> - : never; + : unknown; output: this['schema'] extends this['base'] ? IfDefined, 'json-schema-to-ts'> - : never; + : unknown; } diff --git a/packages/main/src/index.ts b/packages/main/src/index.ts index 9a0904c4..4e4ecf66 100644 --- a/packages/main/src/index.ts +++ b/packages/main/src/index.ts @@ -2,12 +2,7 @@ * This file is generated. Do not modify it manually! */ -import type { - InputFrom, - OutputFrom, - SchemaFrom, - UnknownIfNever, -} from '@typeschema/core'; +import type {InputFrom, OutputFrom, SchemaFrom} from '@typeschema/core'; import { createAssert, @@ -21,12 +16,8 @@ import {validationAdapter} from './validation'; import {serializationAdapter} from './serialization'; export type Schema = SchemaFrom; -export type Infer = UnknownIfNever< - OutputFrom ->; -export type InferIn = UnknownIfNever< - InputFrom ->; +export type Infer = OutputFrom; +export type InferIn = InputFrom; export const validate = createValidate(validationAdapter); export const assert = createAssert(validate); diff --git a/packages/ow/src/index.ts b/packages/ow/src/index.ts index c5a15869..5a232c40 100644 --- a/packages/ow/src/index.ts +++ b/packages/ow/src/index.ts @@ -2,12 +2,7 @@ * This file is generated. Do not modify it manually! */ -import type { - InputFrom, - OutputFrom, - SchemaFrom, - UnknownIfNever, -} from '@typeschema/core'; +import type {InputFrom, OutputFrom, SchemaFrom} from '@typeschema/core'; import { createAssert, @@ -19,12 +14,8 @@ import {AdapterResolver} from './resolver'; import {validationAdapter} from './validation'; export type Schema = SchemaFrom; -export type Infer = UnknownIfNever< - OutputFrom ->; -export type InferIn = UnknownIfNever< - InputFrom ->; +export type Infer = OutputFrom; +export type InferIn = InputFrom; export const validate = createValidate(validationAdapter); export const assert = createAssert(validate); diff --git a/packages/ow/src/resolver.ts b/packages/ow/src/resolver.ts index 68bd58e0..ecc416df 100644 --- a/packages/ow/src/resolver.ts +++ b/packages/ow/src/resolver.ts @@ -3,6 +3,6 @@ import type {Infer, Predicate} from 'ow'; export interface AdapterResolver extends Resolver { base: IfDefined; - input: this['schema'] extends this['base'] ? Infer : never; - output: this['schema'] extends this['base'] ? Infer : never; + input: this['schema'] extends this['base'] ? Infer : unknown; + output: this['schema'] extends this['base'] ? Infer : unknown; } diff --git a/packages/runtypes/src/index.ts b/packages/runtypes/src/index.ts index c5a15869..5a232c40 100644 --- a/packages/runtypes/src/index.ts +++ b/packages/runtypes/src/index.ts @@ -2,12 +2,7 @@ * This file is generated. Do not modify it manually! */ -import type { - InputFrom, - OutputFrom, - SchemaFrom, - UnknownIfNever, -} from '@typeschema/core'; +import type {InputFrom, OutputFrom, SchemaFrom} from '@typeschema/core'; import { createAssert, @@ -19,12 +14,8 @@ import {AdapterResolver} from './resolver'; import {validationAdapter} from './validation'; export type Schema = SchemaFrom; -export type Infer = UnknownIfNever< - OutputFrom ->; -export type InferIn = UnknownIfNever< - InputFrom ->; +export type Infer = OutputFrom; +export type InferIn = InputFrom; export const validate = createValidate(validationAdapter); export const assert = createAssert(validate); diff --git a/packages/runtypes/src/resolver.ts b/packages/runtypes/src/resolver.ts index cbdef086..6e219f2d 100644 --- a/packages/runtypes/src/resolver.ts +++ b/packages/runtypes/src/resolver.ts @@ -3,6 +3,8 @@ import type {Runtype, Static} from 'runtypes'; export interface AdapterResolver extends Resolver { base: IfDefined; - input: this['schema'] extends this['base'] ? Static : never; - output: this['schema'] extends this['base'] ? Static : never; + input: this['schema'] extends this['base'] ? Static : unknown; + output: this['schema'] extends this['base'] + ? Static + : unknown; } diff --git a/packages/superstruct/src/index.ts b/packages/superstruct/src/index.ts index c5a15869..5a232c40 100644 --- a/packages/superstruct/src/index.ts +++ b/packages/superstruct/src/index.ts @@ -2,12 +2,7 @@ * This file is generated. Do not modify it manually! */ -import type { - InputFrom, - OutputFrom, - SchemaFrom, - UnknownIfNever, -} from '@typeschema/core'; +import type {InputFrom, OutputFrom, SchemaFrom} from '@typeschema/core'; import { createAssert, @@ -19,12 +14,8 @@ import {AdapterResolver} from './resolver'; import {validationAdapter} from './validation'; export type Schema = SchemaFrom; -export type Infer = UnknownIfNever< - OutputFrom ->; -export type InferIn = UnknownIfNever< - InputFrom ->; +export type Infer = OutputFrom; +export type InferIn = InputFrom; export const validate = createValidate(validationAdapter); export const assert = createAssert(validate); diff --git a/packages/superstruct/src/resolver.ts b/packages/superstruct/src/resolver.ts index 323c5687..3746a36c 100644 --- a/packages/superstruct/src/resolver.ts +++ b/packages/superstruct/src/resolver.ts @@ -4,6 +4,6 @@ import type {Infer, Struct} from 'superstruct'; export interface AdapterResolver extends Resolver { // eslint-disable-next-line @typescript-eslint/no-explicit-any base: IfDefined, 'superstruct'>; - input: this['schema'] extends this['base'] ? unknown : never; - output: this['schema'] extends this['base'] ? Infer : never; + input: unknown; + output: this['schema'] extends this['base'] ? Infer : unknown; } diff --git a/packages/suretype/src/index.ts b/packages/suretype/src/index.ts index 9a0904c4..4e4ecf66 100644 --- a/packages/suretype/src/index.ts +++ b/packages/suretype/src/index.ts @@ -2,12 +2,7 @@ * This file is generated. Do not modify it manually! */ -import type { - InputFrom, - OutputFrom, - SchemaFrom, - UnknownIfNever, -} from '@typeschema/core'; +import type {InputFrom, OutputFrom, SchemaFrom} from '@typeschema/core'; import { createAssert, @@ -21,12 +16,8 @@ import {validationAdapter} from './validation'; import {serializationAdapter} from './serialization'; export type Schema = SchemaFrom; -export type Infer = UnknownIfNever< - OutputFrom ->; -export type InferIn = UnknownIfNever< - InputFrom ->; +export type Infer = OutputFrom; +export type InferIn = InputFrom; export const validate = createValidate(validationAdapter); export const assert = createAssert(validate); diff --git a/packages/suretype/src/resolver.ts b/packages/suretype/src/resolver.ts index fc551a82..f78456a5 100644 --- a/packages/suretype/src/resolver.ts +++ b/packages/suretype/src/resolver.ts @@ -3,6 +3,8 @@ import type {CoreValidator, TypeOf} from 'suretype'; export interface AdapterResolver extends Resolver { base: IfDefined, 'suretype'>; - input: this['schema'] extends this['base'] ? TypeOf : never; - output: this['schema'] extends this['base'] ? TypeOf : never; + input: this['schema'] extends this['base'] ? TypeOf : unknown; + output: this['schema'] extends this['base'] + ? TypeOf + : unknown; } diff --git a/packages/typebox/src/index.ts b/packages/typebox/src/index.ts index 9a0904c4..4e4ecf66 100644 --- a/packages/typebox/src/index.ts +++ b/packages/typebox/src/index.ts @@ -2,12 +2,7 @@ * This file is generated. Do not modify it manually! */ -import type { - InputFrom, - OutputFrom, - SchemaFrom, - UnknownIfNever, -} from '@typeschema/core'; +import type {InputFrom, OutputFrom, SchemaFrom} from '@typeschema/core'; import { createAssert, @@ -21,12 +16,8 @@ import {validationAdapter} from './validation'; import {serializationAdapter} from './serialization'; export type Schema = SchemaFrom; -export type Infer = UnknownIfNever< - OutputFrom ->; -export type InferIn = UnknownIfNever< - InputFrom ->; +export type Infer = OutputFrom; +export type InferIn = InputFrom; export const validate = createValidate(validationAdapter); export const assert = createAssert(validate); diff --git a/packages/typebox/src/resolver.ts b/packages/typebox/src/resolver.ts index bd70b881..bab4dd9d 100644 --- a/packages/typebox/src/resolver.ts +++ b/packages/typebox/src/resolver.ts @@ -3,6 +3,8 @@ import type {IfDefined, Resolver} from '@typeschema/core'; export interface AdapterResolver extends Resolver { base: IfDefined; - input: this['schema'] extends this['base'] ? Static : never; - output: this['schema'] extends this['base'] ? Static : never; + input: this['schema'] extends this['base'] ? Static : unknown; + output: this['schema'] extends this['base'] + ? Static + : unknown; } diff --git a/packages/valibot/src/index.ts b/packages/valibot/src/index.ts index 9a0904c4..4e4ecf66 100644 --- a/packages/valibot/src/index.ts +++ b/packages/valibot/src/index.ts @@ -2,12 +2,7 @@ * This file is generated. Do not modify it manually! */ -import type { - InputFrom, - OutputFrom, - SchemaFrom, - UnknownIfNever, -} from '@typeschema/core'; +import type {InputFrom, OutputFrom, SchemaFrom} from '@typeschema/core'; import { createAssert, @@ -21,12 +16,8 @@ import {validationAdapter} from './validation'; import {serializationAdapter} from './serialization'; export type Schema = SchemaFrom; -export type Infer = UnknownIfNever< - OutputFrom ->; -export type InferIn = UnknownIfNever< - InputFrom ->; +export type Infer = OutputFrom; +export type InferIn = InputFrom; export const validate = createValidate(validationAdapter); export const assert = createAssert(validate); diff --git a/packages/valibot/src/resolver.ts b/packages/valibot/src/resolver.ts index 7e7e4e7f..5a3dcb3b 100644 --- a/packages/valibot/src/resolver.ts +++ b/packages/valibot/src/resolver.ts @@ -10,8 +10,8 @@ export interface AdapterResolver extends Resolver { base: IfDefined; input: this['schema'] extends this['base'] ? InferInput - : never; + : unknown; output: this['schema'] extends this['base'] ? InferOutput - : never; + : unknown; } diff --git a/packages/valita/src/index.ts b/packages/valita/src/index.ts index c5a15869..5a232c40 100644 --- a/packages/valita/src/index.ts +++ b/packages/valita/src/index.ts @@ -2,12 +2,7 @@ * This file is generated. Do not modify it manually! */ -import type { - InputFrom, - OutputFrom, - SchemaFrom, - UnknownIfNever, -} from '@typeschema/core'; +import type {InputFrom, OutputFrom, SchemaFrom} from '@typeschema/core'; import { createAssert, @@ -19,12 +14,8 @@ import {AdapterResolver} from './resolver'; import {validationAdapter} from './validation'; export type Schema = SchemaFrom; -export type Infer = UnknownIfNever< - OutputFrom ->; -export type InferIn = UnknownIfNever< - InputFrom ->; +export type Infer = OutputFrom; +export type InferIn = InputFrom; export const validate = createValidate(validationAdapter); export const assert = createAssert(validate); diff --git a/packages/valita/src/resolver.ts b/packages/valita/src/resolver.ts index 442697f8..5630d396 100644 --- a/packages/valita/src/resolver.ts +++ b/packages/valita/src/resolver.ts @@ -3,6 +3,6 @@ import type {IfDefined, Resolver} from '@typeschema/core'; export interface AdapterResolver extends Resolver { base: IfDefined; - input: this['schema'] extends this['base'] ? Infer : never; - output: this['schema'] extends this['base'] ? Infer : never; + input: this['schema'] extends this['base'] ? Infer : unknown; + output: this['schema'] extends this['base'] ? Infer : unknown; } diff --git a/packages/vine/src/index.ts b/packages/vine/src/index.ts index c5a15869..5a232c40 100644 --- a/packages/vine/src/index.ts +++ b/packages/vine/src/index.ts @@ -2,12 +2,7 @@ * This file is generated. Do not modify it manually! */ -import type { - InputFrom, - OutputFrom, - SchemaFrom, - UnknownIfNever, -} from '@typeschema/core'; +import type {InputFrom, OutputFrom, SchemaFrom} from '@typeschema/core'; import { createAssert, @@ -19,12 +14,8 @@ import {AdapterResolver} from './resolver'; import {validationAdapter} from './validation'; export type Schema = SchemaFrom; -export type Infer = UnknownIfNever< - OutputFrom ->; -export type InferIn = UnknownIfNever< - InputFrom ->; +export type Infer = OutputFrom; +export type InferIn = InputFrom; export const validate = createValidate(validationAdapter); export const assert = createAssert(validate); diff --git a/packages/vine/src/resolver.ts b/packages/vine/src/resolver.ts index a8d48f85..e15ebba4 100644 --- a/packages/vine/src/resolver.ts +++ b/packages/vine/src/resolver.ts @@ -6,8 +6,8 @@ export interface AdapterResolver extends Resolver { base: IfDefined, '@vinejs/vine'>; input: this['schema'] extends this['base'] ? this['schema'][typeof symbols.ITYPE] - : never; + : unknown; output: this['schema'] extends this['base'] ? this['schema'][typeof symbols.OTYPE] - : never; + : unknown; } diff --git a/packages/yup/src/index.ts b/packages/yup/src/index.ts index 9a0904c4..4e4ecf66 100644 --- a/packages/yup/src/index.ts +++ b/packages/yup/src/index.ts @@ -2,12 +2,7 @@ * This file is generated. Do not modify it manually! */ -import type { - InputFrom, - OutputFrom, - SchemaFrom, - UnknownIfNever, -} from '@typeschema/core'; +import type {InputFrom, OutputFrom, SchemaFrom} from '@typeschema/core'; import { createAssert, @@ -21,12 +16,8 @@ import {validationAdapter} from './validation'; import {serializationAdapter} from './serialization'; export type Schema = SchemaFrom; -export type Infer = UnknownIfNever< - OutputFrom ->; -export type InferIn = UnknownIfNever< - InputFrom ->; +export type Infer = OutputFrom; +export type InferIn = InputFrom; export const validate = createValidate(validationAdapter); export const assert = createAssert(validate); diff --git a/packages/yup/src/resolver.ts b/packages/yup/src/resolver.ts index 80ee1617..ace8b65a 100644 --- a/packages/yup/src/resolver.ts +++ b/packages/yup/src/resolver.ts @@ -5,8 +5,8 @@ export interface AdapterResolver extends Resolver { base: IfDefined; input: this['schema'] extends this['base'] ? InferType - : never; + : unknown; output: this['schema'] extends this['base'] ? InferType - : never; + : unknown; } diff --git a/packages/zod/src/index.ts b/packages/zod/src/index.ts index 9a0904c4..4e4ecf66 100644 --- a/packages/zod/src/index.ts +++ b/packages/zod/src/index.ts @@ -2,12 +2,7 @@ * This file is generated. Do not modify it manually! */ -import type { - InputFrom, - OutputFrom, - SchemaFrom, - UnknownIfNever, -} from '@typeschema/core'; +import type {InputFrom, OutputFrom, SchemaFrom} from '@typeschema/core'; import { createAssert, @@ -21,12 +16,8 @@ import {validationAdapter} from './validation'; import {serializationAdapter} from './serialization'; export type Schema = SchemaFrom; -export type Infer = UnknownIfNever< - OutputFrom ->; -export type InferIn = UnknownIfNever< - InputFrom ->; +export type Infer = OutputFrom; +export type InferIn = InputFrom; export const validate = createValidate(validationAdapter); export const assert = createAssert(validate); diff --git a/packages/zod/src/resolver.ts b/packages/zod/src/resolver.ts index 8674e686..5c5dc67c 100644 --- a/packages/zod/src/resolver.ts +++ b/packages/zod/src/resolver.ts @@ -3,6 +3,8 @@ import type {input, output, ZodType} from 'zod'; export interface AdapterResolver extends Resolver { base: IfDefined; - input: this['schema'] extends this['base'] ? input : never; - output: this['schema'] extends this['base'] ? output : never; + input: this['schema'] extends this['base'] ? input : unknown; + output: this['schema'] extends this['base'] + ? output + : unknown; } diff --git a/turbo/generators/config.ts b/turbo/generators/config.ts index ee596c64..226eff8d 100644 --- a/turbo/generators/config.ts +++ b/turbo/generators/config.ts @@ -121,10 +121,7 @@ function getAdapters(adapterNames: Array): {[key: string]: Adapter} { canInfer: ['input', 'output'].reduce( (result, type) => ({ ...result, - [type]: - resolver?.includes( - `${type}: this['schema'] extends this['base'] ? unknown : never;`, - ) === false, + [type]: resolver?.includes(`${type}: unknown;`) === false, }), {}, ), diff --git a/turbo/generators/templates/adapter/src/index.ts.hbs b/turbo/generators/templates/adapter/src/index.ts.hbs index fc8c6c54..f8e15425 100644 --- a/turbo/generators/templates/adapter/src/index.ts.hbs +++ b/turbo/generators/templates/adapter/src/index.ts.hbs @@ -1,9 +1,4 @@ -import type { - InputFrom, - OutputFrom, - SchemaFrom, - UnknownIfNever, -} from '@typeschema/core'; +import type {InputFrom, OutputFrom, SchemaFrom} from '@typeschema/core'; import { {{#if hasModule.validation}} @@ -25,12 +20,8 @@ import {serializationAdapter} from './serialization'; {{/if}} export type Schema = SchemaFrom; -export type Infer = UnknownIfNever< - OutputFrom ->; -export type InferIn = UnknownIfNever< - InputFrom ->; +export type Infer = OutputFrom; +export type InferIn = InputFrom; {{#if hasModule.validation}} export const validate = createValidate(validationAdapter); diff --git a/turbo/generators/templates/create-adapter/src/resolver.ts.hbs b/turbo/generators/templates/create-adapter/src/resolver.ts.hbs index cd8af1d6..d5cf4547 100644 --- a/turbo/generators/templates/create-adapter/src/resolver.ts.hbs +++ b/turbo/generators/templates/create-adapter/src/resolver.ts.hbs @@ -2,6 +2,6 @@ import type {IfDefined, Resolver} from '@typeschema/core'; export interface AdapterResolver extends Resolver { base: IfDefined<$FixMe, '$FixMe'>; - input: this['schema'] extends this['base'] ? $FixMe : never; - output: this['schema'] extends this['base'] ? $FixMe : never; + input: this['schema'] extends this['base'] ? $FixMe : unknown; + output: this['schema'] extends this['base'] ? $FixMe : unknown; }