Skip to content

Readable prevents type narrowing #2620

Open

Description

@luchsamapparat

openapi-fetch version

0.17.0

Description

After updating to [email protected] and [email protected] I get a type error when accessing a deeply nested property in combination with type narrowing. The original API model is rather complex and in parts driven by code generation requirements from the Java-based backend. However, it is a valid OpenAPI spec and everything worked fine until the update. I think it's the easiest if you take a look at the reproduction linked below.

I could narrow the issue down to the introduction of the Readable type. When I replace the Readable type in openapi-typescript-helpers with type Readable<T> = T everything works fine.

Reproduction

The original OpenAPI spec is from a complex insurance application. I tried to boil it down to the absolute minimum. Without the context it may seem like a rather contrived example, but you have to trust me that it's a valid use case 😉

https://github.com/luchsamapparat/openapi-typescript-readable-bug

Expected result

It should be possible to access tinyFooProp when narrowing the model down via ['@type'] === 'Foo'.

Extra

Activity

  1. added
    bug
    openapi-fetch
    on Feb 13, 2026
  2. added 2 commits that reference this issue on Feb 27, 2026
    b4e97d9
    53281d8
  3. added a commit that references this issue on Mar 11, 2026
    17a9cc1
  4. added a commit that references this issue on Apr 11, 2026
    84ea5cd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugopenapi-fetch

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions