Skip to content

Commit d3724a4

Browse files
Merge pull request #169 from bitgopatmcl/improve-error-format-readability
chore: improve readability of query/param/header types
2 parents 4673303 + 048dd62 commit d3724a4

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

packages/io-ts-http/src/httpRequest.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,17 @@ type EmitOutputTypeErrors<
3737
: {
3838
[K in keyof P & string]: P[K] extends t.Type<any, O, any>
3939
? P[K]
40-
: `Codec's output type is not assignable to ${OName}. Try using one like \`NumberFromString\``;
40+
: `Codec's output type is not assignable to \`${OName}\`. Try using one like \`NumberFromString\``;
4141
};
4242

43+
type QueryValue = string | string[] | undefined;
44+
type ParamValue = string | undefined;
45+
type HeaderValue = string | undefined;
46+
4347
type EmitPropsErrors<P extends HttpRequestCombinatorProps> = {
44-
params?: EmitOutputTypeErrors<P['params'], string | undefined, 'string | undefined'>;
45-
query?: EmitOutputTypeErrors<
46-
P['query'],
47-
string | string[] | undefined,
48-
'string | string[] | undefined'
49-
>;
50-
headers?: EmitOutputTypeErrors<
51-
P['headers'],
52-
string | undefined,
53-
'string | undefined'
54-
>;
48+
params?: EmitOutputTypeErrors<P['params'], ParamValue, 'string | undefined'>;
49+
query?: EmitOutputTypeErrors<P['query'], QueryValue, 'string | string[] | undefined'>;
50+
headers?: EmitOutputTypeErrors<P['headers'], HeaderValue, 'string | undefined'>;
5551
};
5652

5753
export function httpRequest<

0 commit comments

Comments
 (0)