On a fresh project setup via yarn and create-react-app, when I specific the typescript template, The project fails to build.
I have updated to the latest stable version of Yarn 1 (1.22.4) and latest version of create-react-app ([email protected])
Searched any references to typescript and the error as it presents itself.
Occurs both on Mac OS Catalina and WSL
yarn create react-app project --template typescriptcd projectyarn run builderror also present on yarn start
Build success.
yarn run build
yarn run v1.22.4
$ react-scripts build
Creating an optimized production build...
Failed to compile.
/home/matwrz/project/node_modules/@types/testing-library__react/node_modules/pretty-format/build/index.d.ts
TypeScript error in /home/matwrz/project/node_modules/@types/testing-library__react/node_modules/pretty-format/build/index.d.ts(7,13):
'=' expected. TS1005
5 | * LICENSE file in the root directory of this source tree.
6 | */
> 7 | import type * as PrettyFormat from './types';
| ^
8 | /**
9 | * Returns a presentation string of your `val` object
10 | * @param val any potential JavaScript object
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Project that CRA generates from yarn create react-app project --template typescript
https://github.com/MatWrz/cra-project-issue
I'm also having the same error.
Looks like it's caused by version 25.2.0 of pretty-format used by @types/testing-library__react. As a temporary fix you can manually install 25.1.0, remove node_modules and package-lock.json and it'll work:
npx create-react-app my-project --template typescript
cd my-project && npm install [email protected] --save-exact
rm -r node_modules package-lock.json
npm install && npm start
The related issue in the pretty-format repo: https://github.com/facebook/jest/issues/9703
I updated typescript to 3.8.3 and works. maybe some Issues related to the compiler?
Updating typescript worked for me too, thx @hlebon
Related QA: https://stackoverflow.com/a/60856373/11872246
Related Issue: https://github.com/facebook/create-react-app/issues/8714
The issue is now well known and resolved. Thanks everyone! 馃槃
Most helpful comment
I updated typescript to 3.8.3 and works. maybe some Issues related to the compiler?