Skip to content

tuple types are generated as containing unknown #62

@nneonneo

Description

@nneonneo

Consider the following simple model:

from pydantic import BaseModel

class Sprite(BaseModel):
    path: str | None
    crop: tuple[int, int, int, int]
    hotspot: tuple[int, int]

Running uvx --from 'pydantic-to-typescript>=2' pydantic2ts --module test.py --output test.ts produces

/* tslint:disable */
/* eslint-disable */
/**
/* This file was automatically generated from pydantic models by running pydantic2ts.
/* Do not modify it by hand - just update the pydantic models and then re-run the script
*/

export interface Sprite {
  path: string | null;
  /**
   * @minItems 4
   * @maxItems 4
   */
  crop: [unknown, unknown, unknown, unknown];
  /**
   * @minItems 2
   * @maxItems 2
   */
  hotspot: [unknown, unknown];
}

The expected behaviour is that the tuples are encoded as e.g. [number, number, number, number].

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions