type WithErrorResponse<T extends Endpoint, ErrorType> = T extends {output: infer O} ? O extends string | number | boolean | null | undefined ? Omit<T, 'output'> & {output: O | ErrorType} : Omit<T, 'output'> & {output: O | ErrorType} : T;type AddToAllSchemaOutputs<S extends Schema, ErrorType> = { [K in keyof S]: { [M in keyof S[K]]: S[K][M] extends Endpoint ? WithErrorResponse<S[K][M], ErrorType> : never; };};export type AddToAllOutputs<T extends HonoBase<any, any>, ErrorType> = T extends HonoBase<infer E, infer S> ? HonoBase<E, AddToAllSchemaOutputs<S, ErrorType>> : T;
type WithErrorResponse<T, ErrorType> = T extends {output: infer O} ? O extends string | number | boolean | null | undefined ? Omit<T, 'output'> & {output: O | ErrorType} : Omit<T, 'output'> & {output: O | ErrorType} : T;export type AddToAllOutputs<T, ErrorType> = T extends HonoBase<infer E, infer S> ? HonoBase< E, { [K in keyof S]: S[K] extends {[method: string]: any} ? { [M in keyof S[K]]: M extends `$${string}` ? WithErrorResponse<S[K][M], ErrorType> : S[K][M]; } : S[K] extends object ? AddToAllOutputs<S[K], ErrorType> : S[K]; } > : T;
type ErrorType = { success: false; errors: {message: string; code: number}[];};export type App = AddToAllOutputs<MyApp, ErrorType>;