-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
[tsgen] Fix overriding Embind's ClassHandle clone method. #23132
base: main
Are you sure you want to change the base?
Conversation
The return type of `clone` should actually be `ThisType<this>` to better match what the JS is actually doing. This also makes it possible to override the clone method.
@@ -31,7 +31,7 @@ export interface ClassHandle { | |||
delete(): void; | |||
deleteLater(): this; | |||
isDeleted(): boolean; | |||
clone(): this; | |||
clone(): ThisType<this>; |
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.
What does this expression do/mean?
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.
IIUC, it's magic marker that changes how the this
type is bound using the context it was declared instead of where it was called from. This is a workaround for some g3 conflicts, but I'm actually leaning towards abandoning this PR and asking that they don't try to override the clone method.
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.
Seems a little magical but LGTM if it fixes the issue!
This is in emscripten 3.1.71 and above, cf emscripten-core/emscripten#22734 There was a temptative fix upstream to no avail: emscripten-core/emscripten#23132
This is in emscripten 3.1.71 and above, cf emscripten-core/emscripten#22734 There was a temptative fix upstream to no avail: emscripten-core/emscripten#23132
The return type of
clone
should actually beThisType<this>
to better match what the JS is actually doing. This also makes it possible to override the clone method.