createClient
Fails with TypeScript Assertion Error for Numeric-Like Property Names (e.g., "-1", "+1")
#1918
Labels
bug 🔥
Something isn't working
Description
When generating a client using
@hey-api/openapi-ts
'screateClient
function, an internal TypeScript assertion error occurs if the OpenAPI specification contains object schemas with property names that resemble numbers, specifically negative or positive signed numbers like"-1"
or"+1"
.The error message is:
Debug Failure. False expression: Negative numbers should be created in combination with createPrefixUnaryExpression
This seems to happen because the underlying code generation process attempts to treat the property name string (e.g.,
"-1"
) as a numeric literal when interacting with the TypeScript compiler API, which expects negative numbers to be constructed differently (usingcreatePrefixUnaryExpression
).Reproducible example or configuration
Steps to Reproduce:
Define an OpenAPI v3 schema for a component containing properties named
"-1"
and"+1"
, similar to the example below.Use
@hey-api/openapi-ts
'screateClient
function, passing this schema as input. Ensure the@hey-api/typescript
plugin (and potentially@hey-api/schemas
orzod
plugins, although the error seems to stem from the core TS generation) is included.Observe the thrown error during generation.
Error Message / Stack Trace:
OpenAPI specification (optional)
System information (optional)
@hey-api/openapi-ts
version:^0.65.0
typescript
version:5.2.2
[Please fill in]
macOS Sonoma 14.5
The text was updated successfully, but these errors were encountered: