diff --git a/packages/ajv-validator/src/index.ts b/packages/ajv-validator/src/index.ts index 768f0d05..37a35960 100644 --- a/packages/ajv-validator/src/index.ts +++ b/packages/ajv-validator/src/index.ts @@ -67,7 +67,7 @@ export function ajvValidator< T, Target extends keyof ValidationTargets, E extends Env = Env, - P extends string = string + P extends string = string, >( target: Target, schema: JSONSchemaType, diff --git a/packages/arktype-validator/src/index.ts b/packages/arktype-validator/src/index.ts index acc26a72..4dbdde8d 100644 --- a/packages/arktype-validator/src/index.ts +++ b/packages/arktype-validator/src/index.ts @@ -23,7 +23,7 @@ export const arktypeValidator = < } = { in: HasUndefined extends true ? { [K in Target]?: I } : { [K in Target]: I } out: { [K in Target]: O } - } + }, >( target: Target, schema: T, diff --git a/packages/auth-js/src/react.tsx b/packages/auth-js/src/react.tsx index 1cdbbcd4..4484e4b0 100644 --- a/packages/auth-js/src/react.tsx +++ b/packages/auth-js/src/react.tsx @@ -225,7 +225,7 @@ export function SessionProvider(props: SessionProviderProps) { } return updatedSession }, - } as SessionContextValue), + }) as SessionContextValue, [session, loading, setSession] ) diff --git a/packages/class-validator/src/index.ts b/packages/class-validator/src/index.ts index 68994381..2754b40f 100644 --- a/packages/class-validator/src/index.ts +++ b/packages/class-validator/src/index.ts @@ -64,7 +64,7 @@ type Hook< E extends Env, P extends string, Target extends keyof ValidationTargets = keyof ValidationTargets, - O = object + O = object, > = ( result: ({ success: true } | { success: false; errors: ValidationError[] }) & { data: T @@ -119,19 +119,19 @@ export const classValidator = < [K in Target]?: K extends 'json' ? In : HasUndefined extends true - ? { [K2 in keyof In]?: ValidationTargets[K][K2] } - : { [K2 in keyof In]: ValidationTargets[K][K2] } + ? { [K2 in keyof In]?: ValidationTargets[K][K2] } + : { [K2 in keyof In]: ValidationTargets[K][K2] } } : { [K in Target]: K extends 'json' ? In : HasUndefined extends true - ? { [K2 in keyof In]?: ValidationTargets[K][K2] } - : { [K2 in keyof In]: ValidationTargets[K][K2] } + ? { [K2 in keyof In]?: ValidationTargets[K][K2] } + : { [K2 in keyof In]: ValidationTargets[K][K2] } } out: { [K in Target]: Output } }, - V extends I = I + V extends I = I, >( target: Target, dataType: T, diff --git a/packages/conform-validator/src/index.ts b/packages/conform-validator/src/index.ts index 98d69fab..9b7a31d2 100644 --- a/packages/conform-validator/src/index.ts +++ b/packages/conform-validator/src/index.ts @@ -32,7 +32,7 @@ export const conformValidator = < form: { [K in keyof In]: FormTargetValue } } out: { form: GetSuccessSubmission } - } + }, >( parse: F, hook?: Hook diff --git a/packages/effect-validator/src/index.ts b/packages/effect-validator/src/index.ts index ece5dfdf..6c636d92 100644 --- a/packages/effect-validator/src/index.ts +++ b/packages/effect-validator/src/index.ts @@ -19,18 +19,18 @@ export const effectValidator = < [K in Target]?: K extends 'json' ? In : HasUndefined extends true - ? { [K2 in keyof In]?: ValidationTargets[K][K2] } - : { [K2 in keyof In]: ValidationTargets[K][K2] } + ? { [K2 in keyof In]?: ValidationTargets[K][K2] } + : { [K2 in keyof In]: ValidationTargets[K][K2] } } : { [K in Target]: K extends 'json' ? In : HasUndefined extends true - ? { [K2 in keyof In]?: ValidationTargets[K][K2] } - : { [K2 in keyof In]: ValidationTargets[K][K2] } + ? { [K2 in keyof In]?: ValidationTargets[K][K2] } + : { [K2 in keyof In]: ValidationTargets[K][K2] } } out: { [K in Target]: Out } - } + }, >( target: Target, schema: S.Schema diff --git a/packages/event-emitter/src/index.ts b/packages/event-emitter/src/index.ts index ace600e7..3b37f006 100644 --- a/packages/event-emitter/src/index.ts +++ b/packages/event-emitter/src/index.ts @@ -35,7 +35,7 @@ export interface Emitter { export const defineHandler = < EPMap extends EventPayloadMap, Key extends keyof EPMap, - E extends Env = Env + E extends Env = Env, >( handler: EventHandler ): EventHandler => { diff --git a/packages/oauth-providers/src/providers/twitch/types.ts b/packages/oauth-providers/src/providers/twitch/types.ts index d3f44383..84c7c140 100644 --- a/packages/oauth-providers/src/providers/twitch/types.ts +++ b/packages/oauth-providers/src/providers/twitch/types.ts @@ -162,7 +162,7 @@ export interface TwitchUserResponse { view_count: number email: string created_at: string - } + }, ] } diff --git a/packages/prometheus/src/standardMetrics.ts b/packages/prometheus/src/standardMetrics.ts index 811df79b..97b392c7 100644 --- a/packages/prometheus/src/standardMetrics.ts +++ b/packages/prometheus/src/standardMetrics.ts @@ -44,7 +44,7 @@ const getMetricConstructor = (type: MetricOptions['type']) => ({ counter: Counter, histogram: Histogram, - }[type]) + })[type] export const createStandardMetrics = ({ registry, diff --git a/packages/standard-validator/src/index.test.ts b/packages/standard-validator/src/index.test.ts index 5cee33ff..e53297f8 100644 --- a/packages/standard-validator/src/index.test.ts +++ b/packages/standard-validator/src/index.test.ts @@ -9,9 +9,8 @@ import * as zodSchemas from './__schemas__/zod' import { sValidator } from '.' type ExtractSchema = T extends Hono ? S : never -type MergeDiscriminatedUnion = UnionToIntersection extends infer O - ? { [K in keyof O]: O[K] } - : never +type MergeDiscriminatedUnion = + UnionToIntersection extends infer O ? { [K in keyof O]: O[K] } : never const libs = ['valibot', 'zod', 'arktype'] as const const schemasByLibrary = { diff --git a/packages/standard-validator/src/index.ts b/packages/standard-validator/src/index.ts index 70b0c3e0..7ee8ab19 100644 --- a/packages/standard-validator/src/index.ts +++ b/packages/standard-validator/src/index.ts @@ -10,7 +10,7 @@ type Hook< E extends Env, P extends string, Target extends keyof ValidationTargets = keyof ValidationTargets, - O = {} + O = {}, > = ( result: ( | { success: true; data: T } @@ -42,7 +42,7 @@ const sValidator = < } out: { [K in Target]: Out } }, - V extends I = I + V extends I = I, >( target: Target, schema: Schema, diff --git a/packages/swagger-ui/src/swagger/renderer.ts b/packages/swagger-ui/src/swagger/renderer.ts index 399f6abf..6a2b012d 100644 --- a/packages/swagger-ui/src/swagger/renderer.ts +++ b/packages/swagger-ui/src/swagger/renderer.ts @@ -148,7 +148,7 @@ export const renderSwaggerUIOptions = (options: DistSwaggerUIOptions) => { return '' } }) - .filter(item => item !== '') + .filter((item) => item !== '') .join(',') return optionsStrings diff --git a/packages/typebox-validator/src/index.ts b/packages/typebox-validator/src/index.ts index d36a7de1..19cbc652 100644 --- a/packages/typebox-validator/src/index.ts +++ b/packages/typebox-validator/src/index.ts @@ -68,7 +68,7 @@ export function tbValidator< V extends { in: { [K in Target]: Static } out: { [K in Target]: ExcludeResponseType> } - } + }, >( target: Target, schema: T, diff --git a/packages/typia-validator/src/http.ts b/packages/typia-validator/src/http.ts index 938b1f9e..aef42f09 100644 --- a/packages/typia-validator/src/http.ts +++ b/packages/typia-validator/src/http.ts @@ -11,54 +11,57 @@ interface IFailure { type BaseType = T extends string ? string : T extends number - ? number - : T extends boolean - ? boolean - : T extends symbol - ? symbol - : T extends bigint - ? bigint - : T -type Parsed = T extends Record - ? { - [K in keyof T]-?: T[K] extends (infer U)[] - ? (BaseType | null | undefined)[] | undefined - : BaseType | null | undefined - } - : BaseType + ? number + : T extends boolean + ? boolean + : T extends symbol + ? symbol + : T extends bigint + ? bigint + : T +type Parsed = + T extends Record + ? { + [K in keyof T]-?: T[K] extends (infer U)[] + ? (BaseType | null | undefined)[] | undefined + : BaseType | null | undefined + } + : BaseType export type QueryValidation = any> = ( input: string | URLSearchParams ) => IValidation export type QueryOutputType = T extends QueryValidation ? O : never -type QueryStringify = T extends Record - ? { - // Suppress to split union types - [K in keyof T]: [T[K]] extends [bigint | number | boolean] - ? `${T[K]}` - : T[K] extends (infer U)[] - ? [U] extends [bigint | number | boolean] - ? `${U}`[] - : T[K] - : T[K] - } - : T +type QueryStringify = + T extends Record + ? { + // Suppress to split union types + [K in keyof T]: [T[K]] extends [bigint | number | boolean] + ? `${T[K]}` + : T[K] extends (infer U)[] + ? [U] extends [bigint | number | boolean] + ? `${U}`[] + : T[K] + : T[K] + } + : T export type HeaderValidation = any> = ( input: Record ) => IValidation export type HeaderOutputType = T extends HeaderValidation ? O : never -type HeaderStringify = T extends Record - ? { - // Suppress to split union types - [K in keyof T]: [T[K]] extends [bigint | number | boolean] - ? `${T[K]}` - : T[K] extends (infer U)[] - ? [U] extends [bigint | number | boolean] - ? `${U}` - : U - : T[K] - } - : T +type HeaderStringify = + T extends Record + ? { + // Suppress to split union types + [K in keyof T]: [T[K]] extends [bigint | number | boolean] + ? `${T[K]}` + : T[K] extends (infer U)[] + ? [U] extends [bigint | number | boolean] + ? `${U}` + : U + : T[K] + } + : T export type HttpHook = ( result: IValidation.ISuccess | IFailure>, @@ -82,7 +85,7 @@ interface TypiaValidator { V extends { in: { query: QueryStringify }; out: { query: O } } = { in: { query: QueryStringify } out: { query: O } - } + }, >( target: 'query', validate: T, @@ -97,7 +100,7 @@ interface TypiaValidator { V extends { in: { header: HeaderStringify }; out: { header: O } } = { in: { header: HeaderStringify } out: { header: O } - } + }, >( target: 'header', validate: T, @@ -116,7 +119,7 @@ interface TypiaValidator { } = { in: { [K in Target]: O } out: { [K in Target]: O } - } + }, >( target: Target, validate: T, diff --git a/packages/typia-validator/src/index.ts b/packages/typia-validator/src/index.ts index 441924f0..ac030fe7 100644 --- a/packages/typia-validator/src/index.ts +++ b/packages/typia-validator/src/index.ts @@ -23,7 +23,7 @@ export const typiaValidator = < } = { in: { [K in Target]: O } out: { [K in Target]: O } - } + }, >( target: Target, validate: T, diff --git a/packages/valibot-validator/src/index.ts b/packages/valibot-validator/src/index.ts index 438cbc95..6e1b2809 100644 --- a/packages/valibot-validator/src/index.ts +++ b/packages/valibot-validator/src/index.ts @@ -14,7 +14,7 @@ export type Hook< E extends Env, P extends string, Target extends keyof ValidationTargets = keyof ValidationTargets, - O = {} + O = {}, > = ( result: SafeParseResult & { target: Target @@ -45,7 +45,7 @@ export const vValidator = < } out: { [K in Target]: Out } }, - V extends I = I + V extends I = I, >( target: Target, schema: T, diff --git a/packages/zod-openapi/src/index.ts b/packages/zod-openapi/src/index.ts index 6e477c34..4ed40042 100644 --- a/packages/zod-openapi/src/index.ts +++ b/packages/zod-openapi/src/index.ts @@ -73,7 +73,7 @@ type IsForm = T extends string type ReturnJsonOrTextOrResponse< ContentType, Content, - Status extends keyof StatusCodeRangeDefinitions | StatusCode + Status extends keyof StatusCodeRangeDefinitions | StatusCode, > = ContentType extends string ? ContentType extends `application/${infer Start}json${infer _End}` ? Start extends '' | `${string}+` | `vnd.${string}+` @@ -88,8 +88,8 @@ type ReturnJsonOrTextOrResponse< > : never : ContentType extends `text/plain${infer _Rest}` - ? TypedResponse, 'text'> - : Response + ? TypedResponse, 'text'> + : Response : never type RequestPart = Part extends keyof R['request'] @@ -101,7 +101,7 @@ type HasUndefined = undefined extends T ? true : false type InputTypeBase< R extends RouteConfig, Part extends string, - Type extends keyof ValidationTargets + Type extends keyof ValidationTargets, > = R['request'] extends RequestTypes ? RequestPart extends ZodType ? { @@ -125,22 +125,22 @@ type InputTypeJson = R['request'] extends RequestTypes ? IsJson extends never ? {} : R['request']['body']['content'][keyof R['request']['body']['content']] extends Record< - 'schema', - ZodSchema - > - ? { - in: { - json: z.input< - R['request']['body']['content'][keyof R['request']['body']['content']]['schema'] - > + 'schema', + ZodSchema + > + ? { + in: { + json: z.input< + R['request']['body']['content'][keyof R['request']['body']['content']]['schema'] + > + } + out: { + json: z.output< + R['request']['body']['content'][keyof R['request']['body']['content']]['schema'] + > + } } - out: { - json: z.output< - R['request']['body']['content'][keyof R['request']['body']['content']]['schema'] - > - } - } - : {} + : {} : {} : {} : {} @@ -151,22 +151,22 @@ type InputTypeForm = R['request'] extends RequestTypes ? IsForm extends never ? {} : R['request']['body']['content'][keyof R['request']['body']['content']] extends Record< - 'schema', - ZodSchema - > - ? { - in: { - form: z.input< - R['request']['body']['content'][keyof R['request']['body']['content']]['schema'] - > + 'schema', + ZodSchema + > + ? { + in: { + form: z.input< + R['request']['body']['content'][keyof R['request']['body']['content']]['schema'] + > + } + out: { + form: z.output< + R['request']['body']['content'][keyof R['request']['body']['content']]['schema'] + > + } } - out: { - form: z.output< - R['request']['body']['content'][keyof R['request']['body']['content']]['schema'] - > - } - } - : {} + : {} : {} : {} : {} @@ -249,8 +249,8 @@ type HonoInit = ConstructorParameters[0] & OpenAPIHo type AsArray = T extends undefined // TODO move to utils? ? [] : T extends any[] - ? T - : [T] + ? T + : [T] /** * Like simplify but recursive @@ -265,17 +265,14 @@ export type DeepSimplify = { /** * Helper to infer generics from {@link MiddlewareHandler} */ -export type OfHandlerType = T extends MiddlewareHandler< - infer E, - infer P, - infer I -> - ? { - env: E - path: P - input: I - } - : never +export type OfHandlerType = + T extends MiddlewareHandler + ? { + env: E + path: P + input: I + } + : never /** * Reduce a tuple of middleware handlers into a single @@ -285,7 +282,7 @@ export type OfHandlerType = T extends MiddlewareHan export type MiddlewareToHandlerType[]> = M extends [ infer First, infer Second, - ...infer Rest + ...infer Rest, ] ? First extends MiddlewareHandler ? Second extends MiddlewareHandler @@ -297,23 +294,22 @@ export type MiddlewareToHandlerType[] OfHandlerType['path'], // Keep path from First OfHandlerType['input'] // Keep input from First >, - ...Rest + ...Rest, ] > : never : never : never : M extends [infer Last] - ? Last // Return the last remaining handler in the array - : MiddlewareHandler + ? Last // Return the last remaining handler in the array + : MiddlewareHandler type RouteMiddlewareParams = OfHandlerType< MiddlewareToHandlerType> > -export type RouteConfigToEnv = RouteMiddlewareParams extends never - ? Env - : RouteMiddlewareParams['env'] +export type RouteConfigToEnv = + RouteMiddlewareParams extends never ? Env : RouteMiddlewareParams['env'] export type RouteHandler< R extends RouteConfig, @@ -324,7 +320,7 @@ export type RouteHandler< InputTypeCookie & InputTypeForm & InputTypeJson, - P extends string = ConvertPathType + P extends string = ConvertPathType, > = Handler< E, P, @@ -352,7 +348,7 @@ export type RouteHook< InputTypeCookie & InputTypeForm & InputTypeJson, - P extends string = ConvertPathType + P extends string = ConvertPathType, > = Hook< I, E, @@ -371,7 +367,7 @@ export type OpenAPIObjectConfigure = export class OpenAPIHono< E extends Env = Env, S extends Schema = {}, - BasePath extends string = '/' + BasePath extends string = '/', > extends Hono { openAPIRegistry: OpenAPIRegistry defaultHook?: OpenAPIHonoOptions['defaultHook'] @@ -421,7 +417,7 @@ export class OpenAPIHono< InputTypeCookie & InputTypeForm & InputTypeJson, - P extends string = ConvertPathType + P extends string = ConvertPathType, >( { middleware: routeMiddleware, hide, ...route }: R, handler: Handler< @@ -609,7 +605,7 @@ export class OpenAPIHono< SubPath extends string, SubEnv extends Env, SubSchema extends Schema, - SubBasePath extends string + SubBasePath extends string, >( path: SubPath, app: Hono @@ -619,7 +615,7 @@ export class OpenAPIHono< SubPath extends string, SubEnv extends Env, SubSchema extends Schema, - SubBasePath extends string + SubBasePath extends string, >( path: SubPath, app?: Hono diff --git a/packages/zod-validator/src/index.ts b/packages/zod-validator/src/index.ts index 8a96e9d3..9af06db8 100644 --- a/packages/zod-validator/src/index.ts +++ b/packages/zod-validator/src/index.ts @@ -8,7 +8,7 @@ export type Hook< E extends Env, P extends string, Target extends keyof ValidationTargets = keyof ValidationTargets, - O = {} + O = {}, > = ( result: ({ success: true; data: T } | { success: false; error: ZodError; data: T }) & { target: Target @@ -39,7 +39,7 @@ export const zValidator = < } out: { [K in Target]: Out } }, - V extends I = I + V extends I = I, >( target: Target, schema: T,