Skip to content

fix: wrong $d type#2405

Merged
kazupon merged 1 commit intomasterfrom
fix/1113
Feb 25, 2026
Merged

fix: wrong $d type#2405
kazupon merged 1 commit intomasterfrom
fix/1113

Conversation

@kazupon
Copy link
Copy Markdown
Member

@kazupon kazupon commented Feb 25, 2026

resolve #1113

related #2098

Summary by CodeRabbit

  • New Features
    • DateTime formatting function now accepts ISO 8601 string inputs (e.g., '2022-08-08T08:56:45.846Z') in addition to Date objects, providing greater flexibility when formatting dates from various data sources.

@kazupon kazupon added the Type: Bug Bug or Bug fixes label Feb 25, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 25, 2026

📝 Walkthrough

Walkthrough

Extends the $d datetime formatting function's TypeScript type definitions to accept ISO 8601 string inputs alongside existing number and Date types. Updates type overloads across the core composer and Vue module augmentations, with corresponding test coverage additions.

Changes

Cohort / File(s) Summary
Datetime Formatting Type Definitions
packages/vue-i18n/src/vue.d.ts, packages/vue-i18n/src/vue.ts
Widened generic type constraints on $d overloads from `Value extends number
Test Coverage
packages/vue-i18n-core/test/composer.test-d.ts
Added type tests verifying that the d formatting function accepts ISO 8601 string input ('2022-08-08T08:56:45.846Z') and returns expected string type with locale/key options.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Possibly related PRs

Suggested labels

🔨 p3-minor-bug

Poem

🐰 Strings and dates now dance together,
ISO formats, light as feather,
Type definitions bloom and flex,
Datetime formatting's coming next!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: wrong $d type' clearly and concisely describes the main change—correcting TypeScript type definitions for the $d datetime formatter to accept string inputs in addition to Date.
Linked Issues check ✅ Passed The PR successfully addresses issue #1113 by extending $d method signatures across three files to accept string inputs (Date | string) in addition to existing number and Date types, directly resolving the reported TypeScript compile-time errors.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the $d type issue: type signature updates in test declarations, Vue plugin type definitions, and component properties—no extraneous modifications present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/1113

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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 and usage tips.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying vue-i18n-next with  Cloudflare Pages  Cloudflare Pages

Latest commit: a1ce118
Status: ✅  Deploy successful!
Preview URL: https://3dd15f68.vue-i18n-next.pages.dev
Branch Preview URL: https://fix-1113.vue-i18n-next.pages.dev

View logs

@github-actions
Copy link
Copy Markdown

Size Report

Bundles

File Size Gzip Brotli
core.esm-browser.prod.js 44.09 kB 12.69 kB 11.37 kB
core.global.prod.js 35.10 kB 11.74 kB 10.54 kB
core.runtime.esm-browser.prod.js 26.80 kB 8.31 kB 7.45 kB
core.runtime.global.prod.js 20.23 kB 7.66 kB 6.89 kB
message-compiler.esm-browser.prod.js 23.42 kB 6.50 kB 5.83 kB
message-compiler.global.prod.js 20.66 kB 6.26 kB 5.62 kB
petite-vue-i18n-core.esm-browser.prod.js 23.37 kB 7.61 kB 6.82 kB
petite-vue-i18n-core.global.prod.js 17.77 kB 6.75 kB 6.08 kB
petite-vue-i18n.esm-browser.prod.js 43.19 kB 12.58 kB 11.26 kB
petite-vue-i18n.global.prod.js 34.17 kB 11.28 kB 10.16 kB
petite-vue-i18n.runtime.esm-browser.prod.js 25.76 kB 8.10 kB 7.31 kB
petite-vue-i18n.runtime.global.prod.js 19.29 kB 7.18 kB 6.48 kB
vue-i18n.esm-browser.prod.js 56.81 kB 16.25 kB 14.56 kB
vue-i18n.global.prod.js 44.80 kB 14.64 kB 13.19 kB
vue-i18n.runtime.esm-browser.prod.js 39.36 kB 11.77 kB 10.64 kB
vue-i18n.runtime.global.prod.js 29.92 kB 10.58 kB 9.58 kB

Usages

Name Size Gzip Brotli
packages/size-check-core (@intlify/core) 12.00 kB 4.77 kB 4.29 kB
packages/size-check-petite-vue-i18n (petite-vue-i18n) 84.29 kB 32.27 kB 29.10 kB
packages/size-check-vue-i18n (vue-i18n) 88.98 kB 33.58 kB 30.29 kB

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Feb 25, 2026

Open in StackBlitz

@intlify/core

npm i https://pkg.pr.new/@intlify/core@2405

@intlify/core-base

npm i https://pkg.pr.new/@intlify/core-base@2405

@intlify/devtools-types

npm i https://pkg.pr.new/@intlify/devtools-types@2405

@intlify/message-compiler

npm i https://pkg.pr.new/@intlify/message-compiler@2405

petite-vue-i18n

npm i https://pkg.pr.new/petite-vue-i18n@2405

@intlify/shared

npm i https://pkg.pr.new/@intlify/shared@2405

vue-i18n

npm i https://pkg.pr.new/vue-i18n@2405

@intlify/vue-i18n-core

npm i https://pkg.pr.new/@intlify/vue-i18n-core@2405

commit: a1ce118

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
packages/vue-i18n/src/vue.d.ts (1)

497-509: JSDoc param descriptions for $d should mention string inputs.

All $d overloads (including this base one) describe value as "A value, timestamp number or Date instance" but string/ISO 8601 is now a valid input type per this PR. This inconsistency will surface in IDE tooltips.

📝 Suggested JSDoc update (applies to all `$d` overload doc blocks)
- * `@param` value - A value, timestamp number or `Date` instance
+ * `@param` value - A value, timestamp number, `Date` instance, or ISO 8601 date string
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/vue-i18n/src/vue.d.ts` around lines 497 - 509, Update the JSDoc for
the $d datetime formatter (and all its overloads) to document that the value
parameter accepts string inputs (e.g., ISO 8601) in addition to a timestamp
number or Date; specifically, modify the `@param` description for $d (and
references like Composer#d) to read something like "A value — timestamp number,
Date instance, or ISO 8601/string" so IDE tooltips reflect the actual accepted
types.
packages/vue-i18n-core/test/composer.test-d.ts (1)

346-351: Test coverage for string inputs is incomplete — missing the (value, key, locale) overload and the part: true return type.

The added tests cover d(string), d(string, key), and d(string, options) — but skip:

  • d(string, key, locale) — the 3-arg overload whose signature was widened
  • d(string, { ..., part: true }) — to confirm the IsPart conditional return type (Intl.DateTimeFormatPart[]) still works with string inputs
✅ Suggested additional test cases
  expectTypeOf(
    strictDirectComposer.d('2022-08-08T08:56:45.846Z', { key: 'short', locale: 'zh' })
  ).toEqualTypeOf<string>()
+  expectTypeOf(
+    strictDirectComposer.d('2022-08-08T08:56:45.846Z', 'short', 'ja-JP')
+  ).toEqualTypeOf<string>()
+  expectTypeOf(
+    strictDirectComposer.d('2022-08-08T08:56:45.846Z', {
+      key: 'short',
+      locale: 'zh',
+      part: true
+    })
+  ).toEqualTypeOf<Intl.DateTimeFormatPart[]>()
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/vue-i18n-core/test/composer.test-d.ts` around lines 346 - 351, Add
tests for the missing d overloads on strictDirectComposer: call
strictDirectComposer.d('2022-08-08T08:56:45.846Z', 'short', 'zh') and assert its
type is string; also call strictDirectComposer.d('2022-08-08T08:56:45.846Z', {
key: 'short', locale: 'zh', part: true }) and assert its type is
Intl.DateTimeFormatPart[] (or the library's IsPart result) to verify the (value,
key, locale) 3-arg overload and the part:true conditional return type are
covered.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/vue-i18n-core/test/composer.test-d.ts`:
- Around line 346-351: Add tests for the missing d overloads on
strictDirectComposer: call strictDirectComposer.d('2022-08-08T08:56:45.846Z',
'short', 'zh') and assert its type is string; also call
strictDirectComposer.d('2022-08-08T08:56:45.846Z', { key: 'short', locale: 'zh',
part: true }) and assert its type is Intl.DateTimeFormatPart[] (or the library's
IsPart result) to verify the (value, key, locale) 3-arg overload and the
part:true conditional return type are covered.

In `@packages/vue-i18n/src/vue.d.ts`:
- Around line 497-509: Update the JSDoc for the $d datetime formatter (and all
its overloads) to document that the value parameter accepts string inputs (e.g.,
ISO 8601) in addition to a timestamp number or Date; specifically, modify the
`@param` description for $d (and references like Composer#d) to read something
like "A value — timestamp number, Date instance, or ISO 8601/string" so IDE
tooltips reflect the actual accepted types.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d055524 and a1ce118.

📒 Files selected for processing (3)
  • packages/vue-i18n-core/test/composer.test-d.ts
  • packages/vue-i18n/src/vue.d.ts
  • packages/vue-i18n/src/vue.ts

@kazupon kazupon merged commit 0c473b0 into master Feb 25, 2026
36 checks passed
@kazupon kazupon deleted the fix/1113 branch February 25, 2026 14:50
@kazupon kazupon mentioned this pull request Mar 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

$d accepts string as input

1 participant