Skip to content

refactor!: mark Randomizer as readonly - #4226

Open
ST-DDT wants to merge 1 commit into
test/utils/more-constantsfrom
refactor/randomizer/readonly
Open

ST-DDT wants to merge 1 commit into
test/utils/more-constantsfrom
refactor/randomizer/readonly

Conversation

@ST-DDT

@ST-DDT ST-DDT commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Continuation of the discussion in #4209 (comment)


Mark the Randomizer interface properties as readonly.

export interface Randomizer {
  readonly next: () => number;
  readonly seed: (seed: number | number[]) => void;
}

I also considered only wrapping it inside FakerCore:

interface FakerCore {
  readonly: Readonly<Randomizer>;
}

Which variant should we use?

  1. Randomizer with readonly properties
  2. Readonly<Randomizer> in FakerCore

I prefer 1./the current variant, because it represents our expectation for the type and users can easily extend the type to be writeable. From writeable to readable you need to use explicit casts.


ToDo: Write migration guide after the variant has been chosen.

@ST-DDT ST-DDT added this to the v11.0 milestone Oct 29, 2026
@ST-DDT ST-DDT self-assigned this Oct 29, 2026
@ST-DDT ST-DDT added p: 1-normal Nothing urgent c: refactor PR that affects the runtime behavior, but doesn't add new features or fixes bugs breaking change Cannot be merged when next version is not a major release labels Oct 29, 2026
@codecov

codecov Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (test/utils/more-constants@44876a0). Learn more about missing BASE report.

Additional details and impacted files
@@                     Coverage Diff                      @@
##             test/utils/more-constants    #4226   +/-   ##
============================================================
  Coverage                             ?   99.09%           
============================================================
  Files                                ?     1185           
  Lines                                ?     3978           
  Branches                             ?      708           
============================================================
  Hits                                 ?     3942           
  Misses                               ?       31           
  Partials                             ?        5           
🚀 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.

@ST-DDT ST-DDT added the m: utils Something related to public utils (methods/types) label Oct 29, 2026
@ST-DDT
ST-DDT marked this pull request as ready for review October 29, 2026 21:50
@ST-DDT
ST-DDT requested a review from a team as a code owner October 29, 2026 21:50
@ST-DDT
ST-DDT added this pull request to stack #4228 October 29, 2026 21:51
@netlify

netlify Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for fakerjs ready!

Name Link
🔨 Latest commit 8d0408d
🔍 Latest deploy log https://app.netlify.com/projects/fakerjs/deploys/6ae903e09a6217d764e9ae0b
😎 Deploy Preview https://deploy-preview-4226.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 force-pushed the refactor/randomizer/readonly branch from 58ee43b to 8d0408d Compare November 2, 2026 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change Cannot be merged when next version is not a major release c: refactor PR that affects the runtime behavior, but doesn't add new features or fixes bugs m: utils Something related to public utils (methods/types) p: 1-normal Nothing urgent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant