💥 Merge asyncToStringMethod into toStringMethod - #7181
Open
dubzzz wants to merge 1 commit into
Open
Conversation
🦋 Changeset detectedLatest commit: 734f883 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@fast-check/ava
fast-check
@fast-check/jest
@fast-check/packaged
@fast-check/poisoning
@fast-check/vitest
@fast-check/worker
commit: |
In the past we used to have two symbols to define custom serializers for instances: `toStringMethod` for synchronous contexts and `asyncToStringMethod` for asynchronous ones. The two got merged into a single `toStringMethod`: its serializer can now return either a string or a promise of string. Promise-based outputs keep being exploited only in asynchronous contexts. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019H4rz5zF7PTMQK6JCFWh9o
dubzzz
force-pushed
the
claude/merge-tostring-symbols-2qwbsa
branch
from
July 25, 2026 08:11
c4916ff to
734f883
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## next-v4_9_0 #7181 +/- ##
===============================================
- Coverage 95.50% 95.50% -0.01%
===============================================
Files 206 206
Lines 5274 5272 -2
Branches 1470 1471 +1
===============================================
- Hits 5037 5035 -2
Misses 229 229
Partials 8 8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
In the past we used to have two symbols to declare a custom serializer on an instance:
toStringMethodfor synchronous contexts andasyncToStringMethodfor asynchronous ones.The two got merged into a single one:
toStringMethod. Its serializer can now return either a string or a promise of string. In other words, users previously relying onasyncToStringMethodjust have to declare the same serializer ontoStringMethod.Breaking changes (impact flagged as major via a changeset):
asyncToStringMethod,WithAsyncToStringMethodandhasAsyncToStringMethodare dropped from the public API. Migration: replaceasyncToStringMethodbytoStringMethod.WithToStringMethodnow declares() => string | Promise<string>instead of() => string.toStringMethodis now invoked even in synchronous contexts when its output turns out to be a promise (its output simply cannot be leveraged there and fast-check falls back to its default serialization). PreviouslyasyncToStringMethodwas never called in synchronous contexts.Promise-based outputs keep the exact same constraints as
asyncToStringMethodhad: they are only exploited by asynchronous properties and must resolve almost instantly.This PR follows the same direction as previous merges of the sync/async pairs (see the merge of
asyncReporterintoreporterin #7178): with asynchronous properties being the sole way to create properties, keeping two symbols for the same concern was no longer justified.The PR is focused on that single concern. Internal users of the symbols were updated accordingly:
func,streamOfandcommandsnow expose a singletoStringMethodreturning a string when serialization can be done synchronously and a promise otherwise. Existing tests onstringify/asyncStringifyandCommandWrapperwere adapted to the merged symbol — among others they check that Promise-based outputs are used in asynchronous contexts and properly fall back in synchronous ones, and they would have failed without this PR. Documentation (custom-reports.md) was updated too.Checklist
— Don't delete this checklist and make sure you do the following before opening the PR
pnpm run bumpor by following the instructions from the changeset bot🐛(vitest) Something...) when the change targets a package other thanfast-check🤖 Generated with Claude Code
https://claude.ai/code/session_019H4rz5zF7PTMQK6JCFWh9o
Generated by Claude Code