Skip to content

[gaxios] undici-types is not declared as dependency in package.json #927

@chrispisano-bc

Description

@chrispisano-bc

Please make sure you have searched for information in the following guides.

Link to the code that reproduces this issue. A link to a public Github Repository or gist with a minimal reproduction.

https://github.com/chrispisano-bc/bare-bones-bazel

A step-by-step description of how to reproduce the issue, based on the linked reproduction.

Environment details

  • OS: macOS 15.7.4 (24G517)
  • Bazel with aspect_rules_ts 2.4.2
  • aspect_rules_ts 3.6.3 (TypeScript project)
  • Node/npm: 22.11.0
  • pnpm 9.14.2

Steps to reproduce

  1. Clone this repo: https://github.com/chrispisano-bc/bare-bones-bazel
  2. read REPRODUCE.MD
  3. Observe that the type checker cannot resolve undici-types: error TS2307: Cannot find module 'undici-types' or its corresponding type declarations.
  4. Observe that if you install undici-types as a direct dependency or flip skipLibCheck to true, then the reproduce.js script no longer throws.

A clear and concise description of what the bug is, and what you expected to happen.

Description

undici-types is not declared as a direct/optional dependency in gaxios’s package.json, but the published type declarations use it. In packages/gaxios/src/common.ts (and in the emitted build/cjs/src/common.d.ts), the type is defined as:

type _BodyInit = typeof globalThis extends {BodyInit: infer T}
  ? T
  : import('undici-types').BodyInit;

In an isolated build environment (Bazel), this breaks the build if the associated tsconfig file has set skipLibCheck: false

Expected Result

Type-checking succeeds in isolated build environments. Gaxios should either declare undici-types as an optional/direct dependency or the published types should not reference it.

A clear and concise description WHY you expect this behavior, i.e., was it a recent change, there is documentation that points to this behavior, etc. **

I expect library types to compile even when skipLibCheck is set to false

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions