-
Notifications
You must be signed in to change notification settings - Fork 343
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
fix: close https://github.com/cloudflare/workerd/issues/3620 #3621
base: main
Are you sure you want to change the base?
Conversation
I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
I have read the CLA Document and I hereby sign the CLA |
@@ -86,6 +86,7 @@ declare namespace Rpc { | |||
: T extends Set<infer V> ? Set<Stubify<V>> | |||
: T extends Array<infer V> ? Array<Stubify<V>> | |||
: T extends ReadonlyArray<infer V> ? ReadonlyArray<Stubify<V>> | |||
: T extends Rpc.Serializable<T> ? T |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this match plain objects, and thus bypass the next line below? So we won't end up recursively applying Stubify
to the contents of objects?
I guess the problem you're experiencing (in your bug report) is that Date
is matched by the line below, which then tries to recursively Stubify
the properties of Date
, and for some reason it is applying to all the prototype properties like toString
, toDateString
, toTimeString
, and so on. I'm sort of surprised by this though, if [K in keyof T]
actually matches prototype properties, why isn't it constantly getting hung up on Object.prototype
properties which all objects have? Why only Date.prototype
properties?
If this is just the way it works... then I guess what we actually need to do here is define a variant type that's narrower than Serializable
which includes just the builtin types that are explicitly handled, like Date
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may be misreading as I don't know typescript super-well, but doesn't this part of Serializable
match any plain object that is serializable?
| {
[K in keyof T]: K extends number | string ? Serializable<T[K]> : never;
}
And won't that mean that your newly-added line will map any such plain object type to itself, thus bypassing the next line which would otherwise have recursively stubified the contents?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per comment, I think this breaks things as-is.
@penalosa any thoughts on this? |
ref #3620