Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

react-scripts v5 type checks test files when running start command #11979

Open
jwalton9 opened this issue Jan 24, 2022 · 1 comment
Open

react-scripts v5 type checks test files when running start command #11979

jwalton9 opened this issue Jan 24, 2022 · 1 comment

Comments

@jwalton9
Copy link

Describe the bug

When upgrading to react-scripts v5, and running react-scripts start or react-scripts build any .test.ts or .spec.ts file with type errors are reported to the build process and the build fails.

Did you try recovering your dependencies?

I started a fresh project to reproduce the error and the bug still exists

Which terms did you search for in User Guide?

Typescript, types, tests.

Environment

Environment Info:

  current version of create-react-app: 5.0.0
  running from /Users/joewalton/.npm/_npx/c67e74de0542c87c/node_modules/create-react-app

  System:
    OS: macOS 12.0.1
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
  Binaries:
    Node: 16.13.1 - ~/.asdf/installs/nodejs/16.13.1/bin/node
    Yarn: 1.22.17 - ~/.asdf/installs/nodejs/16.13.1/.npm/bin/yarn
    npm: 8.1.2 - ~/.asdf/installs/nodejs/16.13.1/bin/npm
  Browsers:
    Chrome: 97.0.4692.71
    Edge: Not Found
    Firefox: Not Found
    Safari: 15.1
  npmPackages:
    react: ^17.0.2 => 17.0.2
    react-dom: ^17.0.2 => 17.0.2
    react-scripts: ^5.0.0 => 5.0.0
  npmGlobalPackages:
    create-react-app: Not Found

Steps to reproduce

  1. Create a new create-react-app using the typescript template. npx create-react-app my-app --template typescript
  2. Add a type error to src/App.test.tsx
  3. run npm run build

Expected behavior

Type errors should be ignored in test files when running or building app code.

Actual behavior

Type errors are reported in test files when running or building app code.

Reproducible demo

https://github.com/jwalton9/cra-test-type-error

@TrySpace
Copy link

Same issue here, and adding to that, where normally @ts-ignore or @ts-expect-error works, they don't work in the .test files, they are ignored there, but in the main code it still works.

So I think there is some config difference when the tests are ran, it might ignore linting plugins? Or those plugins are outdated and don't support test env?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants