From 048dd62942d16a21002f20614d430a248936b8b5 Mon Sep 17 00:00:00 2001 From: Patrick McLaughlin Date: Tue, 19 Jul 2022 15:44:30 -0400 Subject: [PATCH] chore: improve readability of query/param/header types Helps code readability while keeping the error messages the same. --- packages/io-ts-http/src/httpRequest.ts | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/packages/io-ts-http/src/httpRequest.ts b/packages/io-ts-http/src/httpRequest.ts index fdb8b806..391972d4 100644 --- a/packages/io-ts-http/src/httpRequest.ts +++ b/packages/io-ts-http/src/httpRequest.ts @@ -37,21 +37,17 @@ type EmitOutputTypeErrors< : { [K in keyof P & string]: P[K] extends t.Type ? P[K] - : `Codec's output type is not assignable to ${OName}. Try using one like \`NumberFromString\``; + : `Codec's output type is not assignable to \`${OName}\`. Try using one like \`NumberFromString\``; }; +type QueryValue = string | string[] | undefined; +type ParamValue = string | undefined; +type HeaderValue = string | undefined; + type EmitPropsErrors

= { - params?: EmitOutputTypeErrors; - query?: EmitOutputTypeErrors< - P['query'], - string | string[] | undefined, - 'string | string[] | undefined' - >; - headers?: EmitOutputTypeErrors< - P['headers'], - string | undefined, - 'string | undefined' - >; + params?: EmitOutputTypeErrors; + query?: EmitOutputTypeErrors; + headers?: EmitOutputTypeErrors; }; export function httpRequest<