Created by: kylebebak
Closes #6930 (closed).
Allows users to run and properly build TypeScript projects even if there are TypeScript type check errors.
Motivation and discussion in this issue.
I know it works because I took the react-scripts and react-dev-utils deps from the create-react-app monorepo, edited them with the same changes that are in this PR, and put them in my own repos.
To test it out, you can just create a bare TypeScript app with npx create-react-app cra-typescript --typescript, then change the react-scripts dep as follows.
{
"name": "cra-typescript",
"version": "0.1.0",
"private": true,
"dependencies": {
"@types/jest": "24.0.11",
"@types/node": "11.13.7",
"@types/react": "16.8.14",
"@types/react-dom": "16.8.4",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-scripts": "fortana-co/react-scripts#master",
"typescript": "3.4.5"
},
"scripts": {
"start": "echo 'REACT_APP_ENV=dev\nTSC_COMPILE_ON_ERROR=true' > .env && react-scripts start",
"build": "echo 'REACT_APP_ENV=prod\nTSC_COMPILE_ON_ERROR=true' > .env && react-scripts build",
"build-stg": "echo 'REACT_APP_ENV=stg\nTSC_COMPILE_ON_ERROR=true' > .env && react-scripts build",
"test": "react-scripts test --env=jsdom --modulePaths=src",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
After this you'll be be able to run npm start and npm run build successfully, even if there are type errors. These type errors are printed to the terminal and the browser console.