Skip to content

fix: don't warn about missing id when a spread is present#2581

Open
mogelbrod wants to merge 1 commit into
lingui:mainfrom
mogelbrod:dont-warn-on-id-spread
Open

fix: don't warn about missing id when a spread is present#2581
mogelbrod wants to merge 1 commit into
lingui:mainfrom
mogelbrod:dont-warn-on-id-spread

Conversation

@mogelbrod

Copy link
Copy Markdown
Contributor

Description

Code like below currently triggers a "Missing message ID, skipping" warning on lingui extract, even though it works and is a decent workaround to use placeholders in lazy lookups:

const lookup = {
  x: msg`x {val}`,
  generic: msg`generic {val}`,
}

function X() {
  const { i18n } = useI18n()
  return i18n._({
    ...(lookup.x ?? lookup.generic),
    values: { val: 'test' },
  })
}

I'd like to propose that we stop reporting missing IDs when a spread is also present in the object passed to the i18n._ call.

If this is accepted I'll happily provide patches for the experimental extractor along with the SWC extractor.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Examples update

Checklist

  • I have read the CONTRIBUTING and CODE_OF_CONDUCT docs
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation (if appropriate)

@vercel

vercel Bot commented Jun 24, 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 Jun 24, 2026 4:35pm

Request Review

@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #2581       +/-   ##
===========================================
+ Coverage   77.05%   89.79%   +12.74%     
===========================================
  Files          84      124       +40     
  Lines        2157     3695     +1538     
  Branches      555     1110      +555     
===========================================
+ Hits         1662     3318     +1656     
+ Misses        382      339       -43     
+ Partials      113       38       -75     

☔ 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.

1 participant