Skip to content

OpenAPIParameter.schema.format incompatible with exactOptionalPropertyTypes #105

@ebramanti

Description

@ebramanti

When exactOptionalPropertyTypes: true is enabled (e.g. via @tsconfig/strictest), better-call@1.1.8's OpenAPIParameter type causes type errors for plugins that emit format?: undefined in their OpenAPI parameter metadata.

The issue is in dist/openapi.d.mts (and .d.cts):

schema?: {
  type: OpenAPISchemaType;
  format?: string;  // should be `format?: string | undefined`
};

Under exactOptionalPropertyTypes, format?: string means the property can be absent but if present must be string — it cannot be undefined. Plugins like @better-auth/oauth-provider generate endpoint types where format is explicitly undefined, producing:

Type 'undefined' is not assignable to type 'string'

PR better-auth/better-auth#6502 fixed this class of issue for the OIDC and JWT plugins, but better-call's OpenAPIParameter type still has the same problem, which surfaces through oauth-provider's oauth2Authorize endpoint.

Fix: Change format?: string to format?: string | undefined in the OpenAPIParameter interface.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions