Skip to content

@types from developer dependencies interfere with own project #9731

@poke

Description

@poke

(TypeScript 2.0.0 beta)

Developer dependencies imported using the npm @types namespace interfere with my project specific types.

In my case, I have a web project that should use TypeScript’s default type definitions. My developer dependencies however include something that requires beautylog which itself depends on the package typings-global that has a dependency on @types/node.

This causes some standard definitions to be overwritten with Node-specific definitions. For example, setTimeout() will return a NodeJS.Timer object (instead of a number).

So when using setTimeout() in my web application and attempt to save the return value into a number variable, I get an error since I cannot assign a NodeJS.Timer to that type. But using that NodeJS.Timer type would be wrong since that’s not what happens in the browser.

So a dependency of a dependency of a dependency … has some type definitions which is added into node_modules/@types/ which then causes my project to also load those although they are not relevant (and actually conflicting) to my project.

Is there any solution to this? npm 3’s “let’s try to put everything flat into node_modules” essentially creates a whole new scoping problem with TypeScript 2’s type definition resolution.

(I’ve also created an issue about this on beautylog’s repository.)

Metadata

Metadata

Assignees

Labels

@typesRelates to working with .d.ts files (declaration/definition files) from DefinitelyTypedBugA bug in TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions