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.

Add line numbers / file name for error: "Cannot assign to a reference or variable!"

See original GitHub issue

I’m submitting a … (check one with “x”)

[x] bug report => search github for a similar issue or PR before submitting
[x] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

When getting the error: “Cannot assign to a reference or variable!”:

  • with ng b --aot or ng b --prod: The error consists of ERROR in Cannot assign to a reference or variable! with no line number or file. The following error is the entire module failing to be resolved.
  • with ng b: The error occurs at runtime instead, giving a Unhandled Promise rejection: Cannot assign to a reference or variable! ; Zone: <root> ; Task: Promise.then ; Value: Error: Cannot assign to a reference or variable!, and the stack trace points at vendor.bundle.js.

Expected behavior

When getting the error: “Cannot assign to a reference or variable!”, there should be a file and line number associated with the error.

At the very least, including a component name with the error would suffice in my case.

Minimal reproduction of the problem with instructions

plunker link. Error shows up in console, but doesn’t point the the source of the problem.

What is the motivation / use case for changing the behavior?

Errors should point towards the thing that caused the error. Especially useful since I’m pretty sure I have this error in many places.

Please tell us about your environment:

  • Angular version: 4.1.3
  • Browser: all
  • Language: TypeScript 2.1

  • Node (for AoT issues): node --version = v6.10.2

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:11
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

10reactions
eixincommented, Sep 17, 2019

This continues to be an issue in Angular 8

6reactions
pyrarhum1commented, May 29, 2019

The error occurs when "fullTemplateTypeCheck": true in tsconfig.json.

It’s not possible to find out the error, when you have no stacktrace. 😦.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot assign to 'node.next' because it is borrowed when ...
I can't assign to a variable because it is borrowed even though the reference is out of scope. struct Node<T> { next: Option<Box<Node<T>>>, ......
Read more >
How to add line numbers in every line using shell command?
The right tool for this job is nl : nl -w2 -s'> ' file. You may want to tune w idth option according...
Read more >
Python SyntaxError: can't assign to literal Solution
It is a string. We have tried to assign a value to this literal. This causes an error because variable names must be...
Read more >
Add or remove line numbers - Microsoft Support
On the Page Layout tab, in the Page Setup group, click Line Numbers. Word Ribbon Image · Do one of the following: To...
Read more >
TypeError: can't assign to property "x" on "y": not an object
The problem might be that an unexpected value is flowing at an unexpected place, or that an object variant of a String or...
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