question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[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

image

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.
  • 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:closed
  • Created 4 years ago
  • Reactions:19
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

9reactions
sjmeverettcommented, Apr 8, 2020

Actually I’ve found the problem. react-scripts depends on a specific version of ts-pnp, which doesn’t include the fix.

This will get it to work for now (in .yarnrc.yml):

packageExtensions:
  react-scripts@*:
    dependencies:
      ts-pnp: "^1.2.0"

And you may also need to delete the ts-pnp entries in your yarn.lock

2reactions
arcaniscommented, Mar 26, 2020

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)

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found