-
-
Notifications
You must be signed in to change notification settings - Fork 689
Description
👋 Hello from the TypeScript team. @types/node is overdue on including types for the global fetch and related classes. (The primary obstacle has been figuring out a method of exposing these globals in a way that doesn’t cause TypeScript errors when DOM typings are also present in the compilation, which include very similar but not identical fetch typings. I now have a method that avoids these errors ready to go.)
The last question that has to be resolved for @types/node is where to get the fetch types from. Options that have been explored:
- Add
undicias a dependency of@types/node: we decided that this is best avoided sinceundiciis a fairly large package, and it feels like too much weight to include just for a few kB of.d.tsfiles. - Copy much of undici’s
.d.tsfiles directly into@types/node: I think this is on the table, but the duplication doesn’t feel great. - Move undici’s public API
.d.tsfiles into a new@types/undicipackage that@types/nodecan depend on: It seems like your declaration files are hand-written—if we copied them to DefinitelyTyped, you would have the option of deleting them from this repo (though it would not be required—types included in the package itself will have precedence over ones in@types/undici). We could make any existing undici maintainers owners of the DefinitelyTyped package, which would expedite the review and publishing process when you make changes there. At the same time, the broader DefinitelyTyped community would be able to contribute directly to the maintenance of the types. - Keep the
.d.tsfiles here but publish them separately: If you’d rather keep the declaration files managed in this repo but are opening to publishing a separate package with just the types, that would work well enough for DefinitelyTyped.
We’ll want to pursue one of these options fairly soon, so I wanted to see if any maintainers here had input first. Thanks!
This would solve...
Duplication of fetch types between this repo and @types/node
The implementation should look like...
Me adding types to DefinitelyTyped
I have also considered...
Modularizing the DOM fetch types to eliminate existing duplication with those types—it’s a possible future enhancement, but a large infrastructural change that’s not necessary to implement now for a good resolution.