user195257
user195257

Reputation: 3316

Typescript does not error on compilation with create react app

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"
}

Upvotes: 8

Views: 3476

Answers (1)

olore
olore

Reputation: 4847

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

Upvotes: 3

Related Questions