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(common): fix immutability for locale_data_api #30397
Conversation
I think a better change would be to have this API return |
Thanks for your review. |
Test are failing with error
I don't have any idea what does it mean. |
The issue on here: https://github.com/angular/angular/pull/30397/files#diff-4a042642e9a286cfca1ed035a1fca39aR234 here as well: https://github.com/angular/angular/pull/30397/files#diff-4a042642e9a286cfca1ed035a1fca39aR297 |
@artem-galas - would you mind rebasing this on master? |
Can you also tighten up the commit message a bit so that readers of the changelog will understand more what has changed. Perhaps something more like:
|
I just realised that this will probably fail due to the public API change. We will need to update the public API "golden files"... |
As this is a breaking change to the public API, it could only land in 11.0.0
I think it is worth running a presubmit now to see how many Google projects would be broken by this change. |
Note to Caretakers: since this is a breaking change, we'd need to run Global presubmit as well once master branch is available for v11 changes. |
Adding LGTM for the public-api
group.
Reviewed-for: public-api
Hi @artem-galas, the 10.1.0 version was released last week and master branch is now available for changes that target next major release (v11). Could you please rebase this PR, so that we re-run tests with the current version of master branch? Please let us know (in this thread) once this PR is rebased, so that we re-run tests in Google's codebase. Thank you. |
To discourage developers from mutating the arrays returned from the following methods, their return types have been marked as readonly. * `getLocaleDayPeriods()` * `getLocaleDayNames()` * `getLocaleMonthNames()` * `getLocaleEraNames()` Fixes #27003 BREAKING CHANGE: The locale data API has been marked as returning readonly arrays, rather than mutable arrays, since these arrays are shared across calls to the API. If you were mutating them (e.g. calling `sort()`, `push()`, `splice()`, etc) then your code will not longer compile. If you need to mutate the array, you should now take a copy (e.g. by calling `slice()`) and mutate the copy.
Branch is rebased to latest master. |
FYI, presubmits (including a global one) went well, this PR is ready for merge. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Since no new array instance was returned (on
getLocaleMonthNames
/getLocaleDayNames
methods), after manipulation (e.qsplice
,push
) on array it's not possible to get full list of localized days/month.Issue Number: #27003
What is the new behavior?
Add
Array.from
to return value from these methods.Add general tests for both methods (they didn't have any before), and also add tests for testing bugfix
Does this PR introduce a breaking change?
Other information