Skip to content

fix(core): add bigint to MessagePlaceholder type#2507

Open
pkasarda wants to merge 1 commit into
lingui:main-renamedfrom
pkasarda:fix/message-placeholder-bigint-undefined
Open

fix(core): add bigint to MessagePlaceholder type#2507
pkasarda wants to merge 1 commit into
lingui:main-renamedfrom
pkasarda:fix/message-placeholder-bigint-undefined

Conversation

@pkasarda

@pkasarda pkasarda commented Apr 10, 2026

Copy link
Copy Markdown

Problem

Libraries like Zod type validation bounds as number | bigint (e.g. ZodTooSmallIssue.minimum: number | bigint). Passing these values directly in t template literals causes a TypeScript error:

error TS2345: Argument of type 'number | bigint' is not assignable 
to parameter of type 'MessagePlaceholder'.
  Type 'bigint' is not assignable to type 'MessagePlaceholder'.

Solution

Add bigint to the MessagePlaceholder type in @lingui/core/macro:

 export type MessagePlaceholder =
   | string
   | number
+  | bigint
-  | LabeledExpression<string | number>
+  | LabeledExpression<string | number | bigint>

This is consistent with i18n._() which already accepts Values = Record<string, unknown>.

Workaround users currently need

// Zod validation bounds
t`Min. ${Number(min)} characters`  // wrapping in Number()

With this fix:

t`Min. ${min} characters`  // works directly

@vercel

vercel Bot commented Apr 10, 2026

Copy link
Copy Markdown

@pkasarda is attempting to deploy a commit to the Crowdin Team on Vercel.

A member of the Team first needs to authorize it.

@pkasarda pkasarda marked this pull request as draft April 10, 2026 12:56
Libraries like Zod use `bigint` for validation bounds (e.g.
`minimum: number | bigint` on `ZodTooSmallIssue`). Passing these
values to `t` template literals currently requires wrapping in
`Number()`.

Adding `bigint` to `MessagePlaceholder` allows these values to be
passed directly, consistent with `i18n._()` which already accepts
`Record<string, unknown>`.
@pkasarda pkasarda force-pushed the fix/message-placeholder-bigint-undefined branch from 563d052 to 04f486c Compare April 10, 2026 12:57
@pkasarda pkasarda changed the title fix(core): add bigint and undefined to MessagePlaceholder type fix(core): add bigint to MessagePlaceholder type Apr 10, 2026
@pkasarda pkasarda marked this pull request as ready for review April 10, 2026 12:58
@timofei-iatsenko

Copy link
Copy Markdown
Collaborator

Related #2502

@vercel

vercel Bot commented Apr 15, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
js-lingui Ready Ready Preview Apr 15, 2026 2:59pm

Request Review

@codecov

codecov Bot commented Apr 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main-renamed@9990e54). Learn more about missing BASE report.

Additional details and impacted files
@@               Coverage Diff               @@
##             main-renamed    #2507   +/-   ##
===============================================
  Coverage                ?   81.21%           
===============================================
  Files                   ?      104           
  Lines                   ?     2720           
  Branches                ?      725           
===============================================
  Hits                    ?     2209           
  Misses                  ?      364           
  Partials                ?      147           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants