Skip to content

Prevent dependency hell: export dependencies from DefinitelyTyped as peerDependencies #11671

Closed
@nicojs

Description

@nicojs

Not sure where i can post issues on the current export of DefinitelyTyped repo to the @types npm space, please point me to the correct place.

Right now, the @types are populated using the content in the types-2.0 branche on DefinitelyTyped. An excellent choice! Open source is awesome 😄

The problem is that all dependencies marked with /// <reference types="..." /> are exported as dependencies of the package. This becomes a problem when you have multiple dependencies on one single module.

Say for example: i want type definitions for @types/express-serve-static-core and @types/glob. Both right now mark @types/node as a dependency. When using npm 2.x i immediately get these duplicate identifier errors: error TS2300: Duplicate identifier 'BufferEncoding'. When i use npm 3.x, i get some more leeway, because of the flat folder structure, but when one of the modules would require a different version of @types/node, i would again get this error. Effectively: dependency hell.

The problem would be fixed if dependencies would be marked as peerDependencies. I understand that it can be some more work for the developer who wants to use the typings, but it would effectively solve this issue. At least i would want it for modules that define variables on the global scope.

See for example of a failing build see https://travis-ci.org/stryker-mutator/stryker/jobs/168113675

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions