Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): Updates ngForOf iterable error to use RuntimeError code #46526

Closed
wants to merge 1 commit into from

Conversation

jessicajaniuk
Copy link
Contributor

@jessicajaniuk jessicajaniuk commented Jun 27, 2022

This updates the iterable differ error to use more up-to-date error
codes. It also adds a page to the documentation for the error.

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.io application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

The error thrown in ngForOf is a basic throw rather than using tree shakeable error codes with the runtime error class.

Issue Number: Fixes #28240

What is the new behavior?

The error thrown is tree shakable and has a documentation page.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@jessicajaniuk jessicajaniuk added the area: core Issues related to the framework runtime label Jun 27, 2022
@ngbot ngbot bot added this to the Backlog milestone Jun 27, 2022
@AndrewKushnir AndrewKushnir modified the milestones: Backlog, Fixit H1'2022 Jun 27, 2022
@jessicajaniuk jessicajaniuk force-pushed the ngforof-iterable branch 4 times, most recently from b419d0f to 24a5d1f Compare June 27, 2022 21:10
@jessicajaniuk jessicajaniuk changed the title fix(core): Add a better check and error message for ngForOf iterables fix(core): Updates ngForOf iterable error to use RuntimeError code Jun 27, 2022
@jessicajaniuk jessicajaniuk marked this pull request as ready for review June 27, 2022 21:43
Copy link
Contributor

@dylhunn dylhunn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reviewed-for: public-api, fw-common

Looks great!

@pullapprove pullapprove bot requested a review from atscott June 27, 2022 21:44
@jessicajaniuk jessicajaniuk added action: review The PR is still awaiting reviews from at least one requested reviewer aio: preview action: presubmit The PR is in need of a google3 presubmit labels Jun 27, 2022
@mary-poppins
Copy link

You can preview 2b633b4 at https://pr46526-2b633b4.ngbuilds.io/.
You can preview 3d9f388 at https://pr46526-3d9f388.ngbuilds.io/.
You can preview b419d0f at https://pr46526-b419d0f.ngbuilds.io/.
You can preview 24a5d1f at https://pr46526-24a5d1f.ngbuilds.io/.
You can preview 3a72e96 at https://pr46526-3a72e96.ngbuilds.io/.

@jessicajaniuk jessicajaniuk added the target: patch This PR is targeted for the next patch release label Jun 27, 2022
Copy link
Contributor

@AndrewKushnir AndrewKushnir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, just some minor comments 👍

Comment on lines 224 to 226
`Cannot find a differ supporting object '${value}' of type '${
getTypeName(
value)}'. NgFor only supports binding to Iterables, such as Arrays. Did you mean to use the keyvalue pipe?`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we can split the long string into string concat to avoid unexpected formatting:

Suggested change
`Cannot find a differ supporting object '${value}' of type '${
getTypeName(
value)}'. NgFor only supports binding to Iterables, such as Arrays. Did you mean to use the keyvalue pipe?`);
`Cannot find a differ supporting object '${value}' of type '${getTypeName(value)}'. ` +
`NgFor only supports binding to Iterables, such as Arrays. Did you mean to use the keyvalue pipe?`);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can also consider adding the Did you mean to use the keyvalue pipe? only when we come across an object (and add tests for various cases), otherwise it'd appear for other types as well, which might confuse users. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I definitely like that. I've added a check to append that to the error message after detecting if it's an object.

@pullapprove pullapprove bot requested a review from AndrewKushnir June 27, 2022 22:04
This updates the iterable differ error to use more up-to-date error
codes.
@mary-poppins
Copy link

You can preview 3cbefd8 at https://pr46526-3cbefd8.ngbuilds.io/.

@pullapprove pullapprove bot requested a review from AndrewKushnir June 27, 2022 22:37
Copy link
Contributor

@AndrewKushnir AndrewKushnir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed-for: public-api

@jessicajaniuk jessicajaniuk added action: merge The PR is ready for merge by the caretaker action: presubmit The PR is in need of a google3 presubmit and removed action: presubmit The PR is in need of a google3 presubmit action: review The PR is still awaiting reviews from at least one requested reviewer labels Jun 27, 2022
@dylhunn
Copy link
Contributor

dylhunn commented Jun 28, 2022

This PR was merged into the repository by commit f86e094.

@dylhunn dylhunn closed this in f86e094 Jun 28, 2022
dylhunn pushed a commit that referenced this pull request Jun 28, 2022
This updates the iterable differ error to use more up-to-date error
codes.

PR Close #46526
@dylhunn
Copy link
Contributor

dylhunn commented Jun 28, 2022

@jessicajaniuk I think you may actually want a negative error code here since you have a guide added, as per this instruction

crapStone pushed a commit to Calciumdibromid/CaBr2 that referenced this pull request Jul 4, 2022
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [@angular/animations](https://github.com/angular/angular) | dependencies | patch | [`14.0.3` -> `14.0.4`](https://renovatebot.com/diffs/npm/@angular%2fanimations/14.0.3/14.0.4) |
| [@angular/common](https://github.com/angular/angular) | dependencies | patch | [`14.0.3` -> `14.0.4`](https://renovatebot.com/diffs/npm/@angular%2fcommon/14.0.3/14.0.4) |
| [@angular/compiler](https://github.com/angular/angular) | dependencies | patch | [`14.0.3` -> `14.0.4`](https://renovatebot.com/diffs/npm/@angular%2fcompiler/14.0.3/14.0.4) |
| [@angular/compiler-cli](https://github.com/angular/angular) | devDependencies | patch | [`14.0.3` -> `14.0.4`](https://renovatebot.com/diffs/npm/@angular%2fcompiler-cli/14.0.3/14.0.4) |
| [@angular/core](https://github.com/angular/angular) | dependencies | patch | [`14.0.3` -> `14.0.4`](https://renovatebot.com/diffs/npm/@angular%2fcore/14.0.3/14.0.4) |
| [@angular/forms](https://github.com/angular/angular) | dependencies | patch | [`14.0.3` -> `14.0.4`](https://renovatebot.com/diffs/npm/@angular%2fforms/14.0.3/14.0.4) |
| [@angular/platform-browser](https://github.com/angular/angular) | dependencies | patch | [`14.0.3` -> `14.0.4`](https://renovatebot.com/diffs/npm/@angular%2fplatform-browser/14.0.3/14.0.4) |
| [@angular/platform-browser-dynamic](https://github.com/angular/angular) | dependencies | patch | [`14.0.3` -> `14.0.4`](https://renovatebot.com/diffs/npm/@angular%2fplatform-browser-dynamic/14.0.3/14.0.4) |

---

### Release Notes

<details>
<summary>angular/angular</summary>

### [`v14.0.4`](https://github.com/angular/angular/blob/HEAD/CHANGELOG.md#&#8203;1404-2022-06-29)

[Compare Source](angular/angular@14.0.3...14.0.4)

##### animations

| Commit | Type | Description |
| -- | -- | -- |
| [51be9bbe29](angular/angular@51be9bb) | fix | cleanup DOM elements when the root view is removed ([#&#8203;45143](angular/angular#45143)) |
| [999aca86c8](angular/angular@999aca8) | fix | enable shadowElements to leave when their parent does ([#&#8203;46459](angular/angular#46459)) |

##### common

| Commit | Type | Description |
| -- | -- | -- |
| [42aed6b13e](angular/angular@42aed6b) | fix | handle CSS custom properties in NgStyle ([#&#8203;46451](angular/angular#46451)) |

##### core

| Commit | Type | Description |
| -- | -- | -- |
| [1e7f22f00a](angular/angular@1e7f22f) | fix | trigger `ApplicationRef.destroy` when Platform is destroyed ([#&#8203;46497](angular/angular#46497)) |
| [8bde2dbc71](angular/angular@8bde2db) | fix | Update ngfor error code to be negative ([#&#8203;46555](angular/angular#46555)) |
| [57e8fc00eb](angular/angular@57e8fc0) | fix | Updates error to use RuntimeError code ([#&#8203;46526](angular/angular#46526)) |

##### forms

| Commit | Type | Description |
| -- | -- | -- |
| [74a26d870e](angular/angular@74a26d8) | fix | Convert existing reactive errors to use RuntimeErrorCode. ([#&#8203;46560](angular/angular#46560)) |
| [747872212d](angular/angular@7478722) | fix | Update a Forms validator error to use RuntimeError ([#&#8203;46537](angular/angular#46537)) |

##### router

| Commit | Type | Description |
| -- | -- | -- |
| [d6fac9e914](angular/angular@d6fac9e) | fix | Ensure that new `RouterOutlet` instances work after old ones are destroyed ([#&#8203;46554](angular/angular#46554)) |

#### Special Thanks

Alan Agius, Alex Rickabaugh, Andrew Kushnir, Andrew Scott, Bezael, Chad Ramos, Chellappan, Cédric Exbrayat, Dylan Hunn, George Kalpakas, Jeremy Meiss, Jessica Janiuk, Joey Perrott, KMathy, Kristiyan Kostadinov, Paul Gschwendtner, Pawel Kozlowski, Ramesh Thiruchelvam, Vaibhav Kumar, arturovt, dario-piotrowicz and renovate\[bot]

<!-- CHANGELOG SPLIT MARKER -->

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox.

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).

Co-authored-by: cabr2-bot <cabr2.help@gmail.com>
Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1437
Reviewed-by: Epsilon_02 <epsilon_02@noreply.codeberg.org>
Co-authored-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
Co-committed-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jul 29, 2022
@jessicajaniuk jessicajaniuk deleted the ngforof-iterable branch January 27, 2023 16:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker aio: preview area: core Issues related to the framework runtime target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

low hanging fruit: the error messaging for ngFor unable to iterate objects
4 participants