[Breaking] Remove flatten to simplify client types#108
Merged
just-be-dev merged 2 commits intomainfrom Jan 29, 2025
Merged
Conversation
bef869a to
b5d94be
Compare
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.
As I've been working through the python client implementation
WebViewOptionshas been a pretty big complication due to the intersection of types withWebViewTarget. It's the kind of thing easy to express in typescript, but in python you've got to do weird inheritance shenanigans.It's probably helpful if I provide more specifics. This is the typescript and python before this change
Because python doesn't have a good way to express type intersections like typescript does, the whole generation process is overly complicated. Even the typescript types are more complicated than I'd like though. It's a shame because it does make the API nice and simple.
This change removes the rust flatten that causes this weird intersection case and makes these options use a top level union property.
Now the generated typescript is just
and the python will end up looking more like
much more manageable. The tradeoff is, of course, the api surface area (specifically of deno).
Here's how the simple example gets updated
using webview = await createWebView({ title: "Simple", devtools: true, + load: { html: "<h1>Hello, World!</h1>", + }, initializationScript: "console.log('This is printed from initializationScript!')", });Gross, but reduces the overall complexity so very worth it. It's also worth noting that it removes the possibility of potential name collisions between the load options and the broader set of webview options.