We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hello,
I'm looking to use rest.ts with runtypes and tried this example: https://github.com/hmil/rest.ts/wiki/Usage-with-Runtypes. But I'm getting errors in a few places:
const FlowerIndexedAttribute = rt.Union('color', 'name');
gives me:
Argument of type '"color"' is not assignable to parameter of type 'Runtype<unknown>'.ts(2345)
And when I try to use it within main-server.ts:
main-server.ts
const router = buildRouter(flowerAPI, (_) => _ .listFlowers(async () => { return [ { name: '', color: '', id: '' } ] }) )
I get:
Argument of type '() => Promise<{ name: string; color: string; id: string; }[]>' is not assignable to parameter of type 'RouteHandler<Readonly<RemoveKey<RemoveKey<EmptyInitialEndpointDefinition<"GET">, "query"> & { query: { sortBy: Union2<Runtype<unknown>, Runtype<unknown>>; filterBy: Union2<...>; }; }, "response"> & { ...; }>>'. Type 'Promise<{ name: string; color: string; id: string; }[]>' is not assignable to type 'PromiseOrValue<{ tag: "array"; element: { tag: "record"; fields: { name: { tag: "string"; assert: (x: any) => asserts x is string; check: (x: any) => string; validate: (x: any) => Result<string>; guard: (x: any) => x is string; ... 6 more ...; _falseWitness: string; }; color: { ...; }; id: { ...; }; }; ... 14 more ....'. Type 'Promise<{ name: string; color: string; id: string; }[]>' is not assignable to type 'PromiseLike<{ tag: "array"; element: { tag: "record"; fields: { name: { tag: "string"; assert: (x: any) => asserts x is string; check: (x: any) => string; validate: (x: any) => Result<string>; guard: (x: any) => x is string; ... 6 more ...; _falseWitness: string; }; color: { ...; }; id: { ...; }; }; ... 14 more ...;...'. Types of property 'then' are incompatible. Type '<TResult1 = { name: string; color: string; id: string; }[], TResult2 = never>(onfulfilled?: (value: { name: string; color: string; id: string; }[]) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<...>) => Promise<...>' is not assignable to type '<TResult1 = { tag: "array"; element: { tag: "record"; fields: { name: { tag: "string"; assert: (x: any) => asserts x is string; check: (x: any) => string; validate: (x: any) => Result<string>; guard: (x: any) => x is string; ... 6 more ...; _falseWitness: string; }; color: { ...; }; id: { ...; }; }; ... 14 more ...;...'. Types of parameters 'onfulfilled' and 'onfulfilled' are incompatible. Types of parameters 'value' and 'value' are incompatible. Type '{ name: string; color: string; id: string; }[]' is missing the following properties from type '{ tag: "array"; element: { tag: "record"; fields: { name: { tag: "string"; assert: (x: any) => asserts x is string; check: (x: any) => string; validate: (x: any) => Result<string>; guard: (x: any) => x is string; ... 6 more ...; _falseWitness: string; }; color: { ...; }; id: { ...; }; }; ... 14 more ...; _falseWitne...': tag, element, isReadonly, asReadonly, and 11 more.ts(2345)
The text was updated successfully, but these errors were encountered:
Hi @vincentjocodes, this is strange. Can you let me know which version of runtypes you are using?
Sorry, something went wrong.
No branches or pull requests
Hello,
I'm looking to use rest.ts with runtypes and tried this example: https://github.com/hmil/rest.ts/wiki/Usage-with-Runtypes. But I'm getting errors in a few places:
gives me:
And when I try to use it within
main-server.ts
:I get:
The text was updated successfully, but these errors were encountered: