Skip to content

Conversation

Shinigami92
Copy link
Member

There was just a confusion about how TS works, so I added a second test to clarify the difference and resolved the TODO

@Shinigami92 Shinigami92 self-assigned this Jun 28, 2025
@Shinigami92 Shinigami92 requested a review from a team as a code owner June 28, 2025 10:47
@Shinigami92 Shinigami92 requested a review from a team June 28, 2025 10:47
Copy link

netlify bot commented Jun 28, 2025

Deploy Preview for fakerjs ready!

Name Link
🔨 Latest commit 25fd17b
🔍 Latest deploy log https://app.netlify.com/projects/fakerjs/deploys/6861ae67b9c8a30008e06cdc
😎 Deploy Preview https://deploy-preview-3538.fakerjs.dev
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

Copy link

codecov bot commented Jun 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.97%. Comparing base (a53d5a3) to head (25fd17b).

Additional details and impacted files
@@           Coverage Diff           @@
##             next    #3538   +/-   ##
=======================================
  Coverage   99.97%   99.97%           
=======================================
  Files        2880     2880           
  Lines      220510   220510           
  Branches      952      951    -1     
=======================================
+ Hits       220455   220457    +2     
+ Misses         55       53    -2     

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

Copy link
Member

@xDivisionByZerox xDivisionByZerox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get why this is happening and why the extra test works "as expected" - but doesn't that basically mean that the const in the maybe() generic is basically doing nothing.

maybe<const TResult>(

From my understanding the const clause (don't know if that is the right term) can never be meat in this specific scenario.

@Shinigami92
Copy link
Member Author

I get why this is happening and why the extra test works "as expected" - but doesn't that basically mean that the const in the maybe() generic is basically doing nothing.

maybe<const TResult>(

From my understanding the const clause (don't know if that is the right term) can never be meat in this specific scenario.

it has a different behavior for e.g. arrays
see other tests below

@Shinigami92 Shinigami92 force-pushed the test-maybe-const-number branch from 61a680b to 0b274a2 Compare June 29, 2025 20:22
@xDivisionByZerox
Copy link
Member

it has a different behavior for e.g. arrays

That's true. But I'm talking about this specific case. The generic is inferring a return type of a function that is passed in. The function itself could be inferred as const by typescript. But the return type can never as it. itself would need to statically refer to it's return type as const, from my understanding. That's also what you showed by the second test.

@xDivisionByZerox
Copy link
Member

Anyways, my question was regarding the implementation of the maybe method, not the test that is being fixed here. So I'm merging this.

@xDivisionByZerox xDivisionByZerox merged commit bf3fe92 into next Jun 29, 2025
23 checks passed
@xDivisionByZerox xDivisionByZerox deleted the test-maybe-const-number branch June 29, 2025 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants