Skip to content

fix(locale): drop conflicting date options when merging the global config - #1007

Open
arturovt wants to merge 1 commit into
jsverse:masterfrom
arturovt:fix/496-date-pipe-options-merge-conflict
Open

arturovt wants to merge 1 commit into
jsverse:masterfrom
arturovt:fix/496-date-pipe-options-merge-conflict

Conversation

@arturovt

@arturovt arturovt commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

TranslocoDatePipe spread the global date config over the pipe params, so a global dateStyle / timeStyle combined with params like year or month produced a mix that Intl.DateTimeFormat rejects with "Invalid option". The merge now drops dateStyle / timeStyle when the params use explicit component options, and vice versa; non-conflicting keys such as timeZone are still merged.

Closes #496

Summary by CodeRabbit

  • Bug Fixes

    • Improved date formatting when combining default and explicitly provided options.
    • Prevented conflicting date style and component settings from causing formatting errors.
    • Preserved compatible options, such as time zone preferences.
  • Tests

    • Added coverage for option precedence, conflict handling, and retention of compatible settings.

…nfig

TranslocoDatePipe spread the global `date` config over the pipe params,
so a global `dateStyle` / `timeStyle` combined with params like `year` or
`month` produced a mix that `Intl.DateTimeFormat` rejects with "Invalid
option". The merge now drops `dateStyle` / `timeStyle` when the params
use explicit component options, and vice versa; non-conflicting keys such
as `timeZone` are still merged.

Closes jsverse#496
@coderabbitai

coderabbitai Bot commented Aug 30, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ee89b187-b6c1-4985-b14e-7d297711ef14

📥 Commits

Reviewing files that changed from the base of the PR and between 8a78009 and f49897d.

📒 Files selected for processing (3)
  • libs/transloco-locale/src/lib/pipes/transloco-date.pipe.ts
  • libs/transloco-locale/src/lib/shared.ts
  • libs/transloco-locale/src/lib/tests/pipes/transloco-date.pipe.spec.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

Changes

The date pipe now uses mergeDateOptions to resolve conflicts between style and component options. Tests cover option precedence, time zone retention, and compatible style combinations.

Date option merging

Layer / File(s) Summary
Conflict-aware date option merge
libs/transloco-locale/src/lib/shared.ts
Adds mergeDateOptions, which removes conflicting style or component keys before merging date options.
Date pipe integration and validation
libs/transloco-locale/src/lib/pipes/transloco-date.pipe.ts, libs/transloco-locale/src/lib/tests/pipes/transloco-date.pipe.spec.ts
The pipe uses mergeDateOptions. Tests cover component and style precedence, time zone retention, and non-conflicting styles.

Suggested reviewers: shaharkazaz

Merge Risk: ⚪ Minimal · up to f4989

The date pipe now avoids incompatible formatting options while preserving compatible settings such as timeZone. No actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the defect, the new merge behavior, and links issue #496, but it omits most required template sections, including the PR checklist, PR type, current behavior heading, new beha… Complete the repository template. Mark the applicable checklist items and PR type, describe the current and new behavior under the required headings, select Yes or No for breaking changes, and add any required migration details.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: removing conflicting global date options when merging locale date settings.
Linked Issues check ✅ Passed The changes satisfy issue #496. The date pipe now removes conflicting style or component options, preserves non-conflicting options such as timeZone, and adds tests for precedence and conflict handlin…
Out of Scope Changes check ✅ Passed The changes are within scope for issue #496. The helper, date-pipe integration, and focused tests all support the required date-option merge behavior.
Full details: Description check

Explanation

The description explains the defect, the new merge behavior, and links issue #496, but it omits most required template sections, including the PR checklist, PR type, current behavior heading, new behavior heading, and breaking-change selection.

Full details: Linked Issues check

Explanation

The changes satisfy issue #496. The date pipe now removes conflicting style or component options, preserves non-conflicting options such as timeZone, and adds tests for precedence and conflict handling.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Aug 30, 2026

Copy link
Copy Markdown

Open in StackBlitz

@jsverse/transloco

npm i https://pkg.pr.new/jsverse/transloco/@jsverse/transloco@1007

@jsverse/transloco-keys-manager

npm i https://pkg.pr.new/jsverse/transloco/@jsverse/transloco-keys-manager@1007

@jsverse/transloco-locale

npm i https://pkg.pr.new/jsverse/transloco/@jsverse/transloco-locale@1007

@jsverse/transloco-messageformat

npm i https://pkg.pr.new/jsverse/transloco/@jsverse/transloco-messageformat@1007

@jsverse/transloco-optimize

npm i https://pkg.pr.new/jsverse/transloco/@jsverse/transloco-optimize@1007

@jsverse/transloco-persist-lang

npm i https://pkg.pr.new/jsverse/transloco/@jsverse/transloco-persist-lang@1007

@jsverse/transloco-persist-translations

npm i https://pkg.pr.new/jsverse/transloco/@jsverse/transloco-persist-translations@1007

@jsverse/transloco-preload-langs

npm i https://pkg.pr.new/jsverse/transloco/@jsverse/transloco-preload-langs@1007

@jsverse/transloco-schematics

npm i https://pkg.pr.new/jsverse/transloco/@jsverse/transloco-schematics@1007

@jsverse/transloco-scoped-libs

npm i https://pkg.pr.new/jsverse/transloco/@jsverse/transloco-scoped-libs@1007

@jsverse/transloco-utils

npm i https://pkg.pr.new/jsverse/transloco/@jsverse/transloco-utils@1007

@jsverse/transloco-validator

npm i https://pkg.pr.new/jsverse/transloco/@jsverse/transloco-validator@1007

commit: f49897d

@medbenmakhlouf medbenmakhlouf added bug Something isn't working locale Related to the @jsverse/transloco-locale package area: format Date, number, and currency formatting labels Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: format Date, number, and currency formatting bug Something isn't working locale Related to the @jsverse/transloco-locale package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Merging global format settings with pipe parameters cause errors in date pipe

2 participants