Skip to content

fix(date): infer tuples for explicit betweens counts - #4254

Open
manav4u wants to merge 7 commits into
faker-js:nextfrom
manav4u:fix/date-betweens-tuples
Open

manav4u wants to merge 7 commits into
faker-js:nextfrom
manav4u:fix/date-betweens-tuples

Conversation

@manav4u

@manav4u manav4u commented Nov 4, 2026

Copy link
Copy Markdown

Explicit integer counts from 0 to 100 now infer date tuples, so strict callers can destructure a known number of dates without possibly-undefined values. Omitted, optional, ranged, dynamic and larger counts keep Date[]. Runtime generation is unchanged.

Refs #3407. The cap bounds recursive type expansion and is open to maintainer feedback.

AI-assisted patch. Manav selected this issue; human code review is pending. Build, typecheck and tests pass. Full project lint aborts locally in oxlint 1.90.0 with the JS JSDoc plugin enabled, including on an unchanged file; native-only checks pass but do not replace that check.

@netlify

netlify Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for fakerjs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit e30b8ae
🔍 Latest deploy log https://app.netlify.com/projects/fakerjs/deploys/6aecc784f447f26566bb9d84
😎 Deploy Preview https://deploy-preview-4254.fakerjs.dev
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@ST-DDT ST-DDT added c: feature Request for new feature p: 1-normal Nothing urgent m: date Something is referring to the date module labels Nov 4, 2026
@ST-DDT ST-DDT linked an issue Nov 4, 2026 that may be closed by this pull request
9 of 10 tasks
@ST-DDT ST-DDT added the s: pending triage Pending Triage label Nov 4, 2026
@codecov

codecov Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.14%. Comparing base (4120d43) to head (e30b8ae).
⚠️ Report is 3 commits behind head on next.

Additional details and impacted files
@@           Coverage Diff           @@
##             next    #4254   +/-   ##
=======================================
  Coverage   99.14%   99.14%           
=======================================
  Files        1179     1179           
  Lines        3976     3976           
  Branches      709      709           
=======================================
  Hits         3942     3942           
  Misses         29       29           
  Partials        5        5           
Files with missing lines Coverage Δ
src/modules/date/betweens.ts 100.00% <100.00%> (ø)
src/modules/date/module.ts 100.00% <100.00%> (ø)
src/utils/types.ts 100.00% <ø> (ø)

... and 1 file with indirect coverage changes

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

@manav4u
manav4u marked this pull request as ready for review November 5, 2026 07:49
@manav4u
manav4u requested a review from a team as a code owner November 5, 2026 07:49
@ST-DDT

ST-DDT commented Nov 5, 2026

Copy link
Copy Markdown
Member

Requesting team decision regarding this feature.

@manav4u

manav4u commented Nov 5, 2026

Copy link
Copy Markdown
Author

I measured compiler overhead against this PR's base using TypeScript 6.0.3. Full-project median total was 6.095s on base versus 6.165s on the original PR, with overlapping timing ranges; instantiations rose from 142,409 to 154,495. A 100-call typical consumer took 0.48s versus 0.53s, and a deliberately heavy 1,010-call fixture took 0.84s versus 1.10s.

The cap bounds recursion but doesn't make it free. I've split the helper so count guards run once rather than at every recursion step. In the stress fixture, instantiations fell from 108,285 to 48,008; total time changed from 1.10s to 1.07s. This is not evidence of a large speedup or a whole-project speedup. Build, typecheck and 857 date tests pass. Two full-suite Markdown snapshot failures also reproduce on the unchanged PR head in this environment.

These are one-host, one-compiler measurements, not editor or downstream-project guarantees. The API scope and cap are unchanged.

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

Labels

c: feature Request for new feature m: date Something is referring to the date module p: 1-normal Nothing urgent s: pending triage Pending Triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

faker.date.betweens should return a fixed-length tuple type rather than array of Date

2 participants