You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Prevent typescript errors in IDE for newly generated tests (#78247)
When generating a new test with `pnpm new-test`, the IDE will show the
following error when opening the generated `page.tsx` or `layout.tsx`
files:
```sh
'React' refers to a UMD global, but the current file is a module. Consider adding an import instead.ts (2686)
```
This is because by default, the generated test app is covered by the
root `tsconfig.json`, containing `{"jsx": "react-jsx"}` which expects
there to be a `React` import that the template files don't have.
When first running `pnpm next dev` or `pnpm next build`, a local
`tsconfig.json` file is generated for the test app. This config contains
`{"jsx": "preserve"}`, which fixes the initial errors.
To avoid this step, and prevent the initial compiler errors, we can just
copy the `tsconfig.json` as well as the `next-env.d.ts` from the CNA
template files into the new test app. (Those two files are git-ignored,
by the way.)
0 commit comments