Yarn 2 and type errors in 9.4.5-canary.42 #23943
Replies: 2 comments
-
Some further investigations: Instead of peerDependencies or dependencies, optionalDependencies can also be used in this case. The following lines in
optionalDependencies might be a better option to reference external type libraries as, strictly speaking, typescript is not required to write valid javascript. Also, adding |
Beta Was this translation helpful? Give feedback.
-
The |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
When building typescript packages, build process occasionally falls-out with "strange" errors such as:
My Emacs is configured with tide. I used it to navigate to
NextError
(preliminarily runningyarn unplug next
):Thus, typescript cannot find react types and
Error
component gets typeany
. When importing suchNextError
, it has typeany
instead ofJSX
derivative. That is the reason why the build fails. The above screenshots mean that react types dependency is not recognised by yarn 2 and it cannot suggest that dependencies or peerDependencies are missing.Using the hint from Emacs, the following lines can be added to
.yarnrc.yml
:Then, the reported error changes:
So, typescript can now find
'@types/react'
, however it doesn't see mytsconfig.json
, which is located in yarn repository root and has"esModuleInterop": true
line in it.Therefore, copying
https://github.com/vercel/next.js/blob/canary/packages/next/tsconfig.json
to the location of the unplugged next package, which is in my case/home/rh/projects/artizanya-county/.yarn/unplugged/next-virtual-4bd03d0348/node_modules/next
. After that all next type errors are getting resolved andyarn build
completes successfully.Based on the above finding, I would like to suggest to:
@types/react
to next peerDependencies;tsconfig.json
to the next npm package root;*.d.ts
to next peerDependencies (or dependencies) as well.Thank you for the great library!
Beta Was this translation helpful? Give feedback.
All reactions