-
-
Notifications
You must be signed in to change notification settings - Fork 211
Description
Description
Using the provided configuration example, the client generation completes successfully. However, the generated valibot.gen.ts
file contains four TypeScript errors, all caused by the use of v.date()
inside a v.pipe(...)
. These errors prevent successful compilation.
Here’s an example of the problematic generated code:
/**
* the date of the activities to be found
*/
export const vOrgListActivityFeedsParameterDate = v.pipe(v.string(), v.date());
And here’s one of the TypeScript errors corresponding to the code snippet above when compiling:
src/client/valibot.gen.ts:3603:70 - error TS2769: No overload matches this call.
Overload 1 of 21, '(schema: StringSchema<undefined>, item1: BaseSchema<string, unknown, BaseIssue<unknown>> | BaseValidation<string, unknown, BaseIssue<unknown>> | BaseTransformation<...> | BaseMetadata<...>): SchemaWithPipe<...>', gave the following error.
Argument of type 'DateSchema<undefined>' is not assignable to parameter of type 'BaseSchema<string, unknown, BaseIssue<unknown>>'.
Types of property '~standard' are incompatible.
Type 'StandardProps<Date, Date>' is not assignable to type 'StandardProps<string, unknown>'.
Type 'Date' is not assignable to type 'string'.
Overload 2 of 21, '(schema: StringSchema<undefined>, ...items: readonly PipeItem<string, string, BaseIssue<unknown>>[]): SchemaWithPipe<readonly [StringSchema<undefined>, ...PipeItem<string, string, BaseIssue<...>>[]]>', gave the following error.
Argument of type 'DateSchema<undefined>' is not assignable to parameter of type 'PipeItem<string, string, BaseIssue<unknown>>'.
Type 'DateSchema<undefined>' is not assignable to type 'BaseSchema<string, string, BaseIssue<unknown>>'.
Types of property '~standard' are incompatible.
Type 'StandardProps<Date, Date>' is not assignable to type 'StandardProps<string, string>'.
Type 'Date' is not assignable to type 'string'.
This same error occurs at four locations throughout the generated file.
I haven’t fully investigated the root cause, but from some quick testing, it looks like the issue is related to the combination of the valibot
and @hey-api/transformers
plugins (with dates: true
). The generated validator is trying to transform a string to a Date
using v.date()
, which appears to conflict with Valibot’s type expectations in this context.
As an experiment, I tried replacing v.date()
with v.isoDateTime()
, like so:
v.pipe(v.string(), v.isoDateTime())
With that change, the TypeScript errors go away. So perhaps the issue is that v.date()
expects an actual Date
object as input, while v.isoDateTime()
validates string input and may be more appropriate here.
Reproducible example or configuration
import { createClient, UserConfig } from "@hey-api/openapi-ts";
const userConfig: UserConfig = {
input: "https://code.forgejo.org/swagger.v1.json",
output: "src/client",
plugins: [
{
name: "@hey-api/client-fetch",
bundle: true,
baseUrl: "https://code.forgejo.org",
},
{
name: "@hey-api/typescript",
enums: "javascript",
},
{
name: "@hey-api/sdk",
validator: true,
transformer: true,
},
{
name: "valibot",
},
{
name: "@hey-api/transformers",
dates: true,
},
],
logs: {
file: false,
level: "debug",
},
dryRun: false,
};
createClient(userConfig)
.then(() => console.log("Client generation completed successfully"))
.catch((error) => console.error("Failed to generate client:", error));
OpenAPI specification (optional)
https://code.forgejo.org/swagger.v1.json
System information (optional)
Dependencies
@hey-api/client-fetch
version 0.11.0@hey-api/openapi-ts
version 0.69.0valibot
version 1.1.0
Environment
- OS: Windows 11
- Node.js: v22.16.0
- TypeScript: 5.8.3