question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature idea/improvement: allow dev server and build script to run in presence of TypeScript errors

See original GitHub issue

This isn’t a bug report, but rather an idea to make CRA’s TypeScript setup more user-friendly, and more aligned with what I understand to be the “spirit” of TypeScript.

Currently, for projects built with npx create-react-app <app> --typescript, or migrated to TypeScript as per the docs, both npm start and npm build fail in the presence of TypeScript type errors.

The dev server refuses to serve the app if non-fatal type errors are present. The build script builds it just fine, but exits with a non-zero status. In other words, npm build outputs valid code to /build that can deployed to a production server, even as it tells the user that the app “Failed to compile”.

Devs migrating a moderately sized CRA app to TypeScript may literally be faced with thousands of type errors initially. None of these prevents the app from running, either locally or in production, but devs have to correct or ignore every last error (not that easy, given the limitations of @ts-ignore) before they can continue developing the app.

IMO this goes against TypeScript’s philosophy of making the migration path from JS -> TS as easy as possible, and allowing devs to “progressively” add type annotations to their code.

TypeScript devs already have many options at their disposal to prevent deployment of code that has type errors, if they want to impose this constraint on themselves. CRA definitely shouldn’t impose it on them.

At the very least, I think there should be an option to enable or disable this constraint. I understand that CRA’s philosophy is to avoid config wherever possible. If adding an env var, e.g. TSC_COMPILE_ON_ERROR, is not desirable because it means more config, then I think the default behavior should be for CRA to function normally in the presence of type errors, while printing them as warnings to the terminal/browser console.

I opened a PR with changes that do exactly this. Looking forward to hear what people think!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:21
  • Comments:34 (12 by maintainers)

github_iconTop GitHub Comments

13reactions
Yankovskycommented, Jul 9, 2019

Currently it is very difficult and frustrating to develop CRA app with typescript because of this problem. I think that OP approach with adding optional env var is just fine. I even think that by default TS compilation errors should be warnings.

5reactions
ArtyomReshcommented, Jul 9, 2019

It’d be be really helpful and great if this feature was implemented

Read more comments on GitHub >

github_iconTop Results From Across the Web

Typescript transpile errors appear only on production server
As far as I understand, my code runs fine in production without moving them to devDependencies. If I clone my repo on my...
Read more >
Ignoring TypeScript Errors - next.config.js
Ignoring TypeScript Errors. Next.js fails your production build ( next build ) when TypeScript errors are present in your project. If you'd like ......
Read more >
TypeScript errors and how to fix them
A list of common TypeScript errors and how to fix them.
Read more >
Get a catch block error message with TypeScript - Kent C. Dodds
TypeScript forces you to acknowledge you can't know what was thrown making getting the error message a pain. Here's how you can manage...
Read more >
Visual Studio Code Tip: Show TypeScript Errors in Entire Project
First, as mentioned in the GitHub comment liked above, we need to set up a task in VS Code that we will run...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found