8

I have set up a new project using npx create-react-app my-app --template typescript and I haven't changed any config settings.

If I type some code that has a TS error, my IDE (VS Code) will show the error. However, when I run start/build I do not get any compilation errors.

Further to this, npm run build does fail with the error when run on our GitLab CI/CD pipeline.

I have checked my TS versions, both in the project and where my global module is, both are the same version (4.1.3).

As I said, I haven't made any changes to what create react app has generated and I have tried creating a new project and get the same results. Does anyone have any ideas?

EDIT - To add to this, if I run tsc at the root I get the compilation errors, but npm start I do not.

EDIT 2 - This is my scripts in package.json (untouched from what CRA gives us)

"scripts": {
  "start": "react-scripts start",
  "build": "react-scripts build",
  "test": "react-scripts test",
  "eject": "react-scripts eject"
}
7
  • How do you run it locally? Using npm run build? Commented Jan 22, 2021 at 15:34
  • Yes, npm run build and npm run start both compile without errors when it should error. npm run build on GitLab CI/CD pipeline errors as it should. Commented Jan 22, 2021 at 15:36
  • Can you show us the section 'scripts' in your package.json? Commented Jan 22, 2021 at 15:43
  • @gbalduzzi I have added to question, they are untouched from what CRA gives us Commented Jan 22, 2021 at 15:45
  • Please provide more information about the error that you are confronting Commented Jan 24, 2021 at 23:37

1 Answer 1

3

I found I had to do this to see the tsc errors, but I don't like it

  "test": "tsc && react-scripts test",

Edit: Looks like this is, in-fact, the suggested workaround according to https://github.com/facebook/create-react-app/issues/5626

Sign up to request clarification or add additional context in comments.

1 Comment

i tested all the way back to react-scripts@2 and it seems the tests have never been compiled (with tsc), so however they are getting compiled/transpiled, the types are getting ignored

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.