Manually confirmed this fix works - investigating adding unit testing.
Note that for the specific case that this PR was created, it's also viable to upgrade the bundled TypeScript which resolves the compiler error. A benefit of this solution is we could use it for other rare exceptions in the future.
Context
This fixes https://github.com/lit/lit.dev/issues/1128 by providing a path to gracefully recover from bad incremental state.
Testing
Manually confirmed this fix works - investigating adding unit testing.
Note that for the specific case that this PR was created, it's also viable to upgrade the bundled TypeScript which resolves the compiler error. A benefit of this solution is we could use it for other rare exceptions in the future.