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

Create React App does not work with Typescript template #8717

Closed
MatWrz opened this issue Mar 25, 2020 · 7 comments
Closed

Create React App does not work with Typescript template #8717

MatWrz opened this issue Mar 25, 2020 · 7 comments

Comments

@MatWrz
Copy link

MatWrz commented Mar 25, 2020

Describe the bug

On a fresh project setup via yarn and create-react-app, when I specific the typescript template, The project fails to build.

Did you try recovering your dependencies?

I have updated to the latest stable version of Yarn 1 (1.22.4) and latest version of create-react-app ([email protected])

Which terms did you search for in User Guide?

Searched any references to typescript and the error as it presents itself.

Environment

Occurs both on Mac OS Catalina and WSL

Steps to reproduce

  1. yarn create react-app project --template typescript
  2. cd project
  3. yarn run build

error also present on yarn start

Expected behavior

Build success.

Actual behavior

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.

Reproducible demo

Project that CRA generates from yarn create react-app project --template typescript
https://github.com/MatWrz/cra-project-issue

@jbrown
Copy link

jbrown commented Mar 25, 2020

I'm also having the same error.

@ghost
Copy link

ghost commented Mar 25, 2020

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

@ghost
Copy link

ghost commented Mar 25, 2020

The related issue in the pretty-format repo: jestjs/jest#9703

@hlebon
Copy link

hlebon commented Mar 25, 2020

I updated typescript to 3.8.3 and works. maybe some Issues related to the compiler?

@programateus
Copy link

Updating typescript worked for me too, thx @hlebon

@ibarapascal
Copy link

Related QA: https://stackoverflow.com/a/60856373/11872246
Related Issue: #8714

@MatWrz
Copy link
Author

MatWrz commented Mar 27, 2020

The issue is now well known and resolved. Thanks everyone! 😄

@MatWrz MatWrz closed this as completed Mar 27, 2020
@lock lock bot locked and limited conversation to collaborators Apr 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants