[Bug] TypeScript Create React App projects do not work within workspaces.
See original GitHub issue- I’d be willing to implement a fix
More of a maybe on that. I have no idea why this bug occurs. If I get some hint I could possibly help with implementing a fix. The types for jest are installed, so I’m not sure why they cannot be found.
Describe the bug
Failed to compile.
undefined
TypeScript error in undefined(undefined,undefined):
Cannot find type definition file for 'jest'. TS2688
To Reproduce
- Create a workspaces project.
- Create a CRA app within
packages
. e.g.create-react-app app --template typescript --pnp
- I’m not sure the
--pnp
flag does anything. - At this point I delete
yarn.lock
within app, as well as the pnp file.
- I’m not sure the
- Try to run start for the app. e.g.
yarn workspace app start
Here’s a repo: https://github.com/DylanVann/yarn-berry-create-react-app-bug
Environment if relevant (please complete the following information):
- OS: macOS
10.15.2
- Node:
v13.7.0
- Yarn:
v2.0.0-rc.28
Issue Analytics
- State:
- Created 4 years ago
- Reactions:19
- Comments:9 (1 by maintainers)
Top Results From Across the Web
Create-react-app absolute imports don't work with yarn v2 ...
According to Yarn 2+ documentation the link protocol is recommended over aliases and (TypeScript) path mapping: ...
Read more >Build a React App Using TypeScript, Yarn Workspaces ...
We want to have multiple teams work on each React route, different routes will have a different dependencies, we have another team working...
Read more >react-app-rewired - npm
How to rewire your create-react-app project · 1) Install react-app-rewired · 2) Create a config-overrides.js file in the root directory · 3) 'Flip' ......
Read more >TypeScript Compiling with Visual Studio Code
Step 2: Run the TypeScript build ... Select the tsc: build entry. This will produce a HelloWorld.js and HelloWorld.js.map file in the workspace....
Read more >Cannot use jsx unless the '--jsx' flag is provided (React)
If the error is not resolved, make sure your IDE uses the workspace TypeScript version. Open your terminal in your project's root directory...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Actually I’ve found the problem.
react-scripts
depends on a specific version ofts-pnp
, which doesn’t include the fix.This will get it to work for now (in
.yarnrc.yml
):And you may also need to delete the
ts-pnp
entries in youryarn.lock
I didn’t manage to reproduce your issues (even following your repros 😦), but @ucarion provided one lately which had the same error: https://github.com/ucarion/berry-next-typescript-repro
Thanks to this, I’ve just released a fix in ts-pnp which I think should also fix any similar problem. If that’s not the case, please reopen an issue and 🙏🙏🙏 make sure the repro is as simple as possible so that we can get straight to the fix 🙂
(Note: to use the ts-pnp fix: open your lockfile, remove the ts-pnp entries, then run
yarn install
)