Skip to content

Duplicate type declarations with npm link #28265

@lemoinem

Description

@lemoinem

TypeScript Version: 3.2.0-dev.20181031

Search Terms: npm link unrelated types peerDependencies

Code: Cannot be easily shown via simple code.

Expected behavior:
While developing a library with peerDependencies (e.g., rxjs), npm-linked modules can be used during development.

Actual behavior:
npm-linked modules are impossible to use, because the peerDependencies installed in the npm-linked modules (since we have npm install --dev) conflict with the actual peerDependencies.

Playground Link: Cannot be easily shown via simple code.

Related Issues: #20945

While developing a package, say an external Angular Module, we need to test it in a test application to check the integration.

However, this is impossible to do easily. Currently, I have to close all my editors, rename my node_modules, build the application, test, close everything, rename node_modules, edit, build the module and start again.

This is a major pain. This workflow was already hugely requested before (See #20945), but that issue has been locked, without resolution other than "Stop using npm link". This is not a solution during development. Many reproductions are available in the other thread.
npm link is the recommended way of developing packages with npm. And it would be great if TypeScript followed this.

I understand this is far from trivial to solve. Although it has something to do with the was dependencies are loaded across symlinks. (It looks like npm and other tools ignore the node_module, but typescript doesn't, because of symlink shenanigans). This node_modules is above the symlink, and isn't part of the directory hierarchy of the application, but it seems to be crossed-back on the way up while ignoring the symlink.
As I understand it, a solution could be to double check whether the current directory was accessed via a symlink before going up the file hierarchy (and if yes, go up the proper way).

At any rate, it would be great to have feedback from the team regarding an easy and well-documented recommended way for typescript package developers to work and test if npm-link is not the way to go.

Metadata

Metadata

Assignees

Labels

Needs More InfoThe issue still hasn't been fully clarified

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions