Typescript and noEmitOnError regressions/issues

Open
#2,023 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
52/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
node.js, typescript

Research direction

Start with the StackBlitz reproduction linked in the issue and run its npm run build, npm run watch, and npm run typecheck commands. Inspect the @rollup/plugin-typescript handling of noEmitOnError during build and watch mode. Done means all type errors are reported, builds fail without emitting known-bad JavaScript, and watch mode continues and rebuilds after subsequent fixes.

Written by the indexing model from the issue text.

Description

Expected Behavior

When noEmitOnError is set, running npm run build (set to rollup -c rollup.config.js) should show all typecheck errors approximately as tsc does, and then fail. Similarly, npm run watch (set to rollup -c rollup.config.js -w) should keep watching even if there are typecheck errors.

Actual Behavior

When npm run build is run, it displays the first typecheck error and then crashes (with a stack trace that takes up several lines of console space, meaning you have to scroll up to see the one error, but I think thatʼs a different issue). It does not display other errors.

When npm run watch is run, it shows just one error (and long stacktrace) and then looks like itʼs going to continue watching, but when you change the file in a way that still fails to typecheck it crashes immediately. If you change the file in a way that does typecheck, then the watch process neither produces any output to the terminal nor actually builds the file.

Additional Information

I added a typecheck script so npm run typecheck can show you all the errors not just the first.

Several previous issues (#255, #258, #272, #492) recommend turning off noEmitOnError at least during a rollup --watch, and at least one PR (#544) claims to do that. I donʼt find that a good fix for a few reasons

  • The README says that used to be an issue but that itʼs now fine to turn on noEmitOnError
  • I do not want to ever emit javascript I know is bad; I do not want to accidentally run it if I fail to pay attention to the window where rollup --watch is running, and I do not want to accidentally build it and then not realize I have known-bad code.
Dominant language
JavaScript
Stars
3.8k
Forks
635
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rollup/plugins

All issues in rollup/plugins

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.