-
Notifications
You must be signed in to change notification settings - Fork 22
Closed
Description
I get a handful of errors just trying to compile the API spec provided in the examples.
src/api.ts:7:3 - error TS2322: Type 'Type<never, { query: { [x: number]: any; [x: string]: any; }; params: { [x: number]: any; [x: string]: any; }; headers?: {} | undefined; body?: {} | undefined; }, unknown>' is not assignable to type 'HttpRequestCodec<any>'.
Types of property 'encode' are incompatible.
Type 'Encode<never, { query: { [x: number]: any; [x: string]: any; }; params: { [x: number]: any; [x: string]: any; }; headers?: {} | undefined; body?: {} | undefined; }>' is not assignable to type 'Encode<any, { params: { [x: string]: string; }; query: { [x: string]: string | string[]; }; } & { headers?: { [x: string]: string; } | undefined; body?: Json | undefined; }>'.
Type 'any' is not assignable to type 'never'.
7 request: httpRequest({
~~~~~~~
../../node_modules/@api-ts/io-ts-http/dist/src/httpRoute.d.ts:14:14
14 readonly request: HttpRequestCodec<any>;
~~~~~~~
The expected type comes from property 'request' which is declared here on type 'HttpRoute<"get" | "post" | "put" | "delete">'
src/api.ts:9:7 - error TS2322: Type 'StringC' is not assignable to type '"Codec's output type is not assignable to `string | undefined`. Try using one like `NumberFromString`"'.
9 name: t.string,
~~~~
src/api.ts:13:5 - error TS2322: Type 'StringC' is not assignable to type 'Mixed'.
Types of property 'pipe' are incompatible.
Type '<B, IB, A extends IB, OB extends A>(this: Type<A, string, unknown>, ab: Type<B, OB, IB>, name?: string | undefined) => Type<B, string, unknown>' is not assignable to type '<B, IB, A extends IB, OB extends A>(this: Type<A, any, unknown>, ab: Type<B, OB, IB>, name?: string | undefined) => Type<B, any, unknown>'.
The 'this' types of each signature are incompatible.
Type 'Type<A, any, unknown>' is not assignable to type 'Type<IB, string, unknown>'.
Types of property 'is' are incompatible.
Type 'Is<A>' is not assignable to type 'Is<IB>'.
Type predicate 'u is A' is not assignable to 'u is IB'.
Type 'A' is not assignable to type 'IB'.
'IB' could be instantiated with an arbitrary type which could be unrelated to 'A'.
13 200: t.string,
~~~
../../node_modules/@api-ts/io-ts-http/dist/src/httpResponse.d.ts:3:5
3 [K: number | string]: t.Mixed;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The expected type comes from this index signature.
src/api.ts:19:5 - error TS2322: Type 'HttpRoute<"get" | "post" | "put" | "delete">' is not assignable to type 'HttpRoute<"get">'.
Type '"get" | "post" | "put" | "delete"' is not assignable to type '"get"'.
Type '"post"' is not assignable to type '"get"'.
19 get: GetHelloWorld,
~~~
../../node_modules/@api-ts/io-ts-http/dist/src/httpRoute.d.ts:30:32
30 [ApiAction in keyof Spec]: {
~
31 [M in keyof Spec[ApiAction]]: M extends Method ? Spec[ApiAction][M] : `Unsupported HTTP Method. Use "get" | "post" | "put" | "delete"`;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
32 };
~~~~~
The expected type comes from property 'get' which is declared here on type '{ get?: HttpRoute<"get"> | undefined; post?: HttpRoute<"post"> | undefined; put?: HttpRoute<"put"> | undefined; delete?: HttpRoute<"delete"> | undefined; }'
I'm using:
"@api-ts/io-ts-http": "^2.3.0""io-ts": "^2.2.20""@types/node": "^18.15.11"typescript": "^5.0.4"
Cool repo btw, it's a useful library.