Skip to content

Use of OneOf type causing upcasting to any #1019

@andyrichardson

Description

@andyrichardson

Description

The OneOf function hits a call stack limit on larger unions (>8 entities).

Screenshot 2022-12-14 at 13 20 27

Name Version
openapi-typescript 6.1.0
Node.js 19.1.0
Typescript 4.9.4
OS + version macOS 13

Reproduction

Visit this sandbox

Expected result

OneOf type handles larger arguments without issue

Actual result

OneOf type exceeds call stack limit after an array of size 8.

Checklist

Notes

I've done the following as a workaround, although I suspect this will lead to type inaccuracies.

type OneOf<T extends any[]> = T[number];

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingopenapi-tsRelevant to the openapi-typescript library

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions