When running nx serve
(using NRWL NX) on my TypeScript project, the build now fails with this error:
<my-file>.ts - Error: Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
Error: Debug Failure. False expression: Lexical environment is suspended.
<my-file>.ts
1 has not been changed in a couple of days and I think it had already been properly compiling after my last changes to it a few days ago.
I suspect the above might be a bug in the TS compiler or similar, but to properly reproduce this issue in a minimal example, is there anything I can do to find out what particular part of <my-file>.ts
causes the issue, or what constructs I should watch out for that might cause this error?
Some notes about the environment:
nx serve
command launches the @angular-devkit/build-angular:dev-server
executor.@angular-devkit/build-angular:browser
executor to build the project.1: This is a placeholder for the real file name.
I was able to reproduce the same error in the context of a Jest test.
The difference was between a method declaration in an Angular service like this:
public async doSomething<T extends object>(): Promise<{
get value(): number
}> {
// ....
(does not work, produces the "Error: Debug Failure. False expression: Lexical environment is suspended." message)
versus this
public async doSomething<T extends object>(): Promise<{
readonly value: number
}> {
// ....
(works, produces no compiler errors)
Unfortunately, I was unable to reproduce this on the TS Playground, so I still do not have an isolated example that I can report, but maybe this still helps some future visitors.