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.

cant build due to "Optional chaining cannot appear in left-hand side"

See original GitHub issue

Type of Issue

[ x] Bug Report

Description

After running ng build my-publishable-module I get an error durring build

✔ Compiling with Angular sources in Ivy partial compilation mode. ✖ Generating FESM2020 Optional chaining cannot appear in left-hand side (Note that you need plugins to import files that are not JavaScript) Error: Optional chaining cannot appear in left-hand side (Note that you need plugins to import files that are not JavaScript) at error (/Users/omar/Sites/met-libs-nx/node_modules/ng-packagr/node_modules/rollup/dist/shared/rollup.js:159:30) Screen Shot 2022-02-28 at 5 58 56 PM

It looks like @rollup@2.68.0 (/ng-packagr/node_modules/rollup/) throws this error.

There is a lot of chatter about this bug on rollup. but i have not found a solution. https://github.com/rollup/rollup/pull/3582

I tried all the suggestions with rollup and updating it within my project but no luck.

Version Information


Angular CLI: 13.1.3
Node: 14.16.0
Package Manager: npm 6.14.11
OS: darwin x64

Angular: 13.1.2
... animations, common, compiler, compiler-cli, core, forms
... language-service, material, platform-browser
... platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1301.3
@angular-devkit/build-angular   13.1.3
@angular-devkit/core            13.2.5
@angular-devkit/schematics      13.2.5
@angular/cli                    13.1.3
@angular/fire                   7.2.1
@schematics/angular             13.2.5
ng-packagr                      13.1.3
rxjs                            6.6.7
typescript                      4.5.4

Please include all version numbers that might be relevant, e.g. third-party libraries

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
alan-agius4commented, Mar 2, 2022

I believe the problem is caused by the below and since you are using casting you are also bypassing Typescript error reporting.

(this.schema?.fields as Field[])[e.previousContainer.data.index] = e.container.data.item;
(this.schema?.fields as Field[])[e.container.data.index] = e.previousContainer.data.item;
1reaction
alan-agius4commented, Mar 2, 2022

Printing the fileInfo on error https://github.com/rollup/rollup/blob/51cab92373bcf8c844a8de2a6765869f7eb05a5d/src/Module.ts#L836 should give should be enough to determine which file is causing the problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Optional chaining on the left side in Javascript - Stack Overflow
The left-hand side of an assignment expression may not be an optional property access. When attempting something akin to: class A{ b?: string;...
Read more >
The left-hand side of assignment expression may not be an ...
The error "The left-hand side of an assignment expression may not be an optional property access" occurs when we try to use optional...
Read more >
Optional chaining (?.) - JavaScript - MDN Web Docs - Mozilla
Optional chaining not valid on the left-hand side of an assignment. It is invalid to try to assign to the result of an...
Read more >
Why can't the left-hand side of an assignment expression use ...
Why can't the left-hand side of an assignment expression use optional chaining? Why is that not allowed, but function calls are?
Read more >
What is wrong with optional chaining and how to fix it - DEV ...
Unfortunately both versions have the same issue, for z being empty string, it does not call func function. Another issue is that in...
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