googleapis / googleapis/google-cloud-node
[gaxios] `undici-types` is not declared as dependency in package.json
- Dominant language
- TypeScript
- Stars
- 3.2k
- Forks
- 712
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 99
Description
### Please make sure you have searched for information in the following guides.
- [x] Search the issues already opened: https://github.com/googleapis/google-cloud-node-core/issues
- [x] Search StackOverflow: http://stackoverflow.com/questions/tagged/google-cloud-platform+node.js
- [x] Check our Troubleshooting guide: https://github.com/googleapis/google-cloud-node-core/blob/main/docs/troubleshooting.md
- [x] Check our FAQ: https://github.com/googleapis/google-cloud-node-core/blob/main/docs/faq.md
- [x] Check our libraries HOW-TO: https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md
- [x] Check out our authentication guide: https://github.com/googleapis/google-auth-library-nodejs
- [x] Check out handwritten samples for many of our APIs: https://github.com/GoogleCloudPlatform/nodejs-docs-samples
- [x] Check the API's issue tracker: https://cloud.google.com/support/docs/issue-trackers
### 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](https://github.com/googleapis/google-cloud-node-core/blob/7feb4c8cc253c87f8da6ecb078b096a896b4d840/packages/gaxios/src/common.ts#L30-L32) (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`
Contributor guide
Assessment
This issue has not been assessed yet.