Skip to content

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

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

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

Conversation

@pkasarda
Copy link
Copy Markdown

@pkasarda pkasarda commented Apr 10, 2026

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
Copy link
Copy Markdown

vercel Bot commented Apr 10, 2026

@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
Copy link
Copy Markdown

vercel Bot commented Apr 15, 2026

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
Copy link
Copy Markdown

codecov Bot commented Apr 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.21%. Comparing base (6bb8983) to head (04f486c).
⚠️ Report is 268 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2507      +/-   ##
==========================================
+ Coverage   77.05%   81.21%   +4.16%     
==========================================
  Files          84      104      +20     
  Lines        2157     2720     +563     
  Branches      555      725     +170     
==========================================
+ Hits         1662     2209     +547     
+ Misses        382      364      -18     
- Partials      113      147      +34     

☔ View full report in Codecov by Sentry.
📢 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