Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript (tsc) cannot find modules from inside workspace #893

Closed
jeffrson opened this issue Feb 4, 2020 · 4 comments
Closed

Typescript (tsc) cannot find modules from inside workspace #893

jeffrson opened this issue Feb 4, 2020 · 4 comments
Labels
bug Something isn't working external bug This issue highlights a bug in another project stale Issues that didn't get attention

Comments

@jeffrson
Copy link

jeffrson commented Feb 4, 2020

Describe the bug

From inside a workspace in my test project the typescript compiler cannot find a certain referenced module.

To Reproduce

See repo at https://github.com/jeffrson/yarn2_types.git

Environment if relevant (please complete the following information):

  • OS: [e.g. OSX, Linux, Windows, ...] Windows 10
  • Node version [e.g. 8.15.0, 10.15.1, ...] 13.7.0
  • Yarn version [e.g. 2.0.0-rc1, ...] 2.0.0-rc28

Additional context

../../.yarn/$$virtual/subscriptions-transport-ws-virtual-de5b014bf6/0/cache/subscriptions-transport-ws-npm-0.9.16-e352bac494-1.zip/node_modules/subscriptions-transport-ws/dist/server.d.ts:2:28 - error TS7016: Could not find a declaration file for module 'ws'.
'c:/.../workspace/.yarn/cache/ws-npm-5.2.2-173bcd57b2-1.zip/node_modules/ws/index.js' implicitly has an 'any' type.
  Try `npm install @types/ws` if it exists or add a new declaration (.d.ts) file containing `declare module 'ws';`

2 import * as WebSocket from 'ws';
                             ~~~~


Found 2 errors.

command not found: tsc
@jeffrson jeffrson added the bug Something isn't working label Feb 4, 2020
@arcanis
Copy link
Member

arcanis commented Feb 4, 2020

You're using subscriptions-transport-ws, which depends on ws (through here) and thus on @types/ws, but doesn't list @types/ws in either dependencies or peerDependencies (instead only listing it in devDependencies).

So basically your project is fine (you could call import ... from 'ws', the problem is the missing dependency in subscriptions-transport-ws.

As a workaround, use packageExtensions to declare the missing (peer?) dependency, and maybe send a PR upstream to let them know about the issue.

@arcanis arcanis added the external bug This issue highlights a bug in another project label Feb 4, 2020
@jeffrson
Copy link
Author

jeffrson commented Feb 4, 2020

Thank you for the detailed explanation. Thanks also for the suggestion of workaround (which works).

OTOH, shouldn't the error occur without workspace as well?

@yarnbot
Copy link
Collaborator

yarnbot commented Jun 9, 2020

Hi! 👋

This issue looks stale, and doesn't feature the reproducible label - which implies that you didn't provide a working reproduction using Sherlock. As a result, it'll be closed in a few days unless a maintainer explicitly vouches for it or you edit your first post to include a formal reproduction (you can use the playground for that).

Note that we require Sherlock reproductions for long-lived issues (rather than standalone git repositories or similar) because we're a small team. Sherlock gives us the ability to check which bugs are still affecting the master branch at any given point, and decreases the amount of code we need to run on our own machines (thus leading to faster bug resolution faster). It helps us help you! 😃

If you absolutely cannot reproduce a bug on Sherlock (for example because it's a Windows-only issue), a maintainer will have to manually add the upholded label.

@yarnbot yarnbot added the stale Issues that didn't get attention label Jun 9, 2020
@merceyz
Copy link
Member

merceyz commented Jun 10, 2020

Closing as a upstream issue

OTOH, shouldn't the error occur without workspace as well?

Not if you have installed @types/ws as one of your own dependencies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working external bug This issue highlights a bug in another project stale Issues that didn't get attention
Projects
None yet
Development

No branches or pull requests

4 participants