Skip to content

Literal fields are converted to optional any #2019

Open
@DavidRowthorn

Description

@DavidRowthorn

Using version 0.26.0

A class like the following:

class Animal(BaseModel):
    type: Literal["dog"] = "dog"
    name: string

Should generate a typescript class like so:

export type Animal = {
  type: "dog"
  name: string
}

But it generates

export type Animal = {
  type?: any
  name: string
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions