Skip to content

Customizing Generated Date Types to Use Temporal.Instant #1883

@DtechB

Description

@DtechB

Context:

I’m using @hey-api/openapi-ts to generate TypeScript types/schemas from a FastAPI backend’s OpenAPI spec. My frontend (React) uses Temporal.Instant (via @js-temporal/polyfill) for datetime handling, but the generated types default to Date, causing type mismatches.

Problem Example:

// Generated type (simplified)  
interface Event {  
  startTime: Date; // ❌ Needs to be Temporal.Instant  
}  

// Usage  
const event: Event = {  
  startTime: Temporal.Instant.from("2024-01-01T00:00:00Z"), // ❌ Type error  
};  

Questions:

  1. Is there a built-in way to configure @hey-api/openapi-ts to use Temporal types instead of Date?
  2. If not, would a feature request for Temporal support be feasible?
  3. Are there recommended patterns (e.g., type overrides, plugins) to customize datetime types?

Environment:

@hey-api/openapi-ts: 0.56.3
@js-temporal/polyfill: 0.5.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions