Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Documents TSC_COMPILE_ON_ERROR env var; changes message printed to co…
…nsole when an app is built in presence of type errors
  • Loading branch information
kylebebak committed Jul 15, 2019
commit 1955a079d96d56c67c900aa402fb4fddbd99299b
4 changes: 3 additions & 1 deletion docusaurus/docs/adding-typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ yarn add typescript @types/node @types/react @types/react-dom @types/jest

Next, rename any file to be a TypeScript file (e.g. `src/index.js` to `src/index.tsx`) and **restart your development server**!

Type errors will show up in the same console as the build one.
Type errors will show up in the same console as the build one. By default, Create React App prevents you from running the dev server if your code has type errors. If you introduce type errors to your project, you have to fix or ignore them before you continue development.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather we omit this for now, as we don't want users to do this unless they absolutely must. Perhaps just as small snippet like "for advanced configuration, see (advanced config)" - as a terrible example.

That way, people can find it if they need, but they won't assume it's a normal practice to use this.

Ideally, this should never be used unless you're migrating a lot of legacy code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @mrmckeb

I've changed the above to the following:

Type errors will show up in the same console as the build one. You'll have to fix these type errors before you continue development or build your project. For advanced configuration, see here.

Now it doesn't explicitly or even implicitly encourage anyone to do this =)

Thanks for your feedback!


You can remove this restriction by running your app with the `TSC_COMPILE_ON_ERROR` environment variable set to `true`, for example, by adding `TSC_COMPILE_ON_ERROR=true` to your `.env` file. [Read more about setting environment variables here](https://facebook.github.io/create-react-app/docs/adding-custom-environment-variables).

To learn more about TypeScript, check out [its documentation](https://www.typescriptlang.org/).

Expand Down
4 changes: 3 additions & 1 deletion packages/react-scripts/scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ checkBrowsers(paths.appPath, isInteractive)
err => {
const tscCompileOnError = process.env.TSC_COMPILE_ON_ERROR === 'true';
if (tscCompileOnError) {
console.log(chalk.yellow('Compiled with warnings.\n'));
console.log(chalk.red(
'Compiled with the following type errors (you may want to check these before deploying your app):\n'
));
printBuildError(err);
} else {
console.log(chalk.red('Failed to compile.\n'));
Expand Down