-
Notifications
You must be signed in to change notification settings - Fork 13k
Description
(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.)