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

chore(ct): throw error when props are not json serializable #22025

Merged
merged 3 commits into from
Mar 29, 2023

Conversation

sand4rt
Copy link
Collaborator

@sand4rt sand4rt commented Mar 28, 2023

Related to: #21400, #22003

boolean: (value: any) => typeof value === 'boolean',
null: (value: any) => value === null,
array: (value: any) => Array.isArray(value) && value.every(isJson),
object: (value: any) => typeof value === 'object' && value !== null && !Array.isArray(value)
Copy link
Member

Choose a reason for hiding this comment

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

JSON will have a default serializing conventions for types like Date, but I guess it is Ok to be more restrictive here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure if i fully get that. Thought only the string, number, boolean, null, array and object types are JSON serializable? Do you mean that JSON.parse(JSON.stringify({ boop: Date })) will return {} ?

Copy link
Member

Choose a reason for hiding this comment

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

Look at what JSON.stringify({ data: new Date() }) produces, but don't bother.

Copy link
Member

@pavelfeldman pavelfeldman left a comment

Choose a reason for hiding this comment

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

Fix those nits and we are good.

@sand4rt sand4rt marked this pull request as ready for review March 28, 2023 20:02
@sand4rt
Copy link
Collaborator Author

sand4rt commented Mar 28, 2023

Fix those nits and we are good.

Done, also added the check for await component.update({ props: { boop: 'boop' }}) : https://github.com/microsoft/playwright/pull/22025/files#diff-f6515604ba6e73e5ba509d2d713faacc6e09f0a06b1db6ca30d0ca7c6ffb4e55R67

@pavelfeldman pavelfeldman merged commit 9c0c5d6 into microsoft:main Mar 29, 2023
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