Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref: sort options obj and remove optional params #1545

Closed
wants to merge 3 commits into from

Conversation

JonasBa
Copy link
Contributor

@JonasBa JonasBa commented Jul 20, 2024

Feel free to discard this PR, it's more of a suggestion than anything else and would require a new semver major due to the breaking API change, but I found it hard to track the options object around the different call sites (especially as a lot of field are optional and it's hard to know exactly what is being passed vs what is default initialized).

This PR changes that by removing changing all optional field of the serialize options params and sorting it. The goal of the change is to simplify the control flow by not having to look at what is default initialized as well as hopefully reducing the polymorphic argument values.

Copy link

changeset-bot bot commented Jul 20, 2024

🦋 Changeset detected

Latest commit: 63b9db6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 18 packages
Name Type
rrweb-snapshot Major
rrweb Major
@rrweb/rrweb-plugin-canvas-webrtc-record Major
@rrweb/rrweb-plugin-canvas-webrtc-replay Major
@rrweb/rrweb-plugin-console-record Major
@rrweb/rrweb-plugin-console-replay Major
@rrweb/rrweb-plugin-sequential-id-record Major
@rrweb/rrweb-plugin-sequential-id-replay Major
rrdom Major
rrdom-nodejs Major
rrweb-player Major
@rrweb/all Major
@rrweb/replay Major
@rrweb/record Major
@rrweb/types Major
@rrweb/packer Major
@rrweb/web-extension Major
rrvideo Major

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

@eoghanmurray
Copy link
Contributor

I haven't taken the time to understand what these changes are for; but will add one comment would be that given the size of the diff, this will generate a lot of work to merge other large open PRs, e.g. #1475

@JonasBa
Copy link
Contributor Author

JonasBa commented Jul 25, 2024

@eoghanmurray lets skip it then and I will reopen it when your PR is merged. The idea is to reduce the number of argument shapes passed to the function which allows JS engines to make certain optimizations they otherwise wouldnt be able to.

@JonasBa JonasBa closed this Jul 25, 2024
@eoghanmurray
Copy link
Contributor

Thanks @JonasBa for the tricky work and hope we can revisit.
From my own POV (a programming pov) I dislike the many places you have to touch to get a new argument propagated down the call chain. This is a problem when there are multiple open PRs which touch the arguments. I don't know if your solution here also has that sort of simplification benefit.

@eoghanmurray
Copy link
Contributor

I'd personally be in favour of omitting options from the whole typescript system and just checking for their existence (and type) on a generic option object, but I'd say that's just me!

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.

2 participants