Useage with yarn's pnp
FallingSnow opened this issue · comments
atom-typescript seems unable to locate installed modules that are installed with yarn's Plug'n'Play feature. After running yarn add @types/node
I am still presented with Cannot find type definition file for 'node'.
However the project is compilable.
Even when installing other modules I get a similar error: Cannot find 'fastify' or it's corresponding type declarations
.
Okay, I was wrong, some additional setup is needed. All is outlined in yarn docs though:
- Need to explicitly install typescript into project:
specify version and/or omit
yarn add --dev typescript
--dev
if you need to - Need to manually generate vscode configs and tsdk wrappers using pnpify:
or just
yarn dlx @yarnpkg/pnpify --sdk vscode
if you've installed pnpifyyarn pnpify --sdk vscode
- Probably need to restart Atom after those are done.
If all done correctly, active TypeScript version in Atom (right of the bottom status bar) should show up as X.Y.Z-pnpify
instead of X.Y.Z
.
You'll probably need to re-run yarn pnpify --sdk
/yarn dlx @yarnpkg/pnpify --sdk
if you change TypeScript version (e.g. update it)
One caveat is that Atom itself doesn't handle zip:/
URIs that pnpified tsserver likes to output, so jumping to files from installed modules won't work. I'll look into this when I have spare time, but probably not very soon (my backlog is kinda long)
I've run:
yarn add typescript
yarn dlx @yarnpkg/pnpify --sdk vscode
➤ YN0000: ┌ Resolution step
➤ YN0000: └ Completed in 2.53s
➤ YN0000: ┌ Fetch step
➤ YN0013: │ stream-buffers@npm:3.0.2 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ stream-to-array@npm:2.3.0 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ stream-to-promise@npm:2.2.0 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ tunnel@npm:0.0.6 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ underscore@npm:1.10.2 can't be found in the cache and will be fetched from the remote registry
➤ YN0000: └ Completed in 0.86s
➤ YN0000: ┌ Link step
➤ YN0000: └ Completed
➤ YN0000: Done in 3.54s
➤ YN0000: ┌ Generating SDKs inside .yarn/sdks
➤ YN0000: │ • 6 SDKs were skipped based on your root dependencies
➤ YN0000: └ Completed
➤ YN0000: ┌ Generating settings
➤ YN0000: │ ✓ Vscode (new ✨)
➤ YN0000: └ Completed
And restarted atom but the error messages persist and version only shows 3.9.7
. I am using workspaces but I also tried a file at the root repo level (index.ts
) and it produced the same errors.
Yeah, output should have
➤ YN0000: ┌ Generating SDKs inside .yarn/sdks
➤ YN0000: │ ✓ Typescript
➤ YN0000: │ • 5 SDKs were skipped based on your root dependencies
➤ YN0000: └ Completed
Make sure you have typescript
in dependencies
or devDependencies
in package.json
and maybe rerun yarn dlx @yarnpkg/pnpify --sdk
. As I said in other thread, I don't personally use yarn, so not entirely sure what goes wrong there. It should pick up on typescript
in package.json
and act accordingly.
Got it working!
Thanks @lierdakil!
Turned out the key was skipped based on your root dependencies
. Since I was in one of the yarn workspaces for the project when I ran yarn add typescript
it only added it to the workspace dependencies.
So once I added typescript as a dependency in the root folder, reran pnpify, and restarted atom, everything worked as expected. Adding type definitions does require a restart of atom it seems, but I'm completely fine with that. Thanks again!