Skip to content

types: Move to DefinitelyTyped? #2261

@andrewbranch

Description

@andrewbranch

👋 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 undici as a dependency of @types/node: we decided that this is best avoided since undici is a fairly large package, and it feels like too much weight to include just for a few kB of .d.ts files.
  • Copy much of undici’s .d.ts files directly into @types/node: I think this is on the table, but the duplication doesn’t feel great.
  • Move undici’s public API .d.ts files into a new @types/undici package that @types/node can 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.ts files 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.

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    TypesChanges related to the TypeScript definitionsenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions