-
Notifications
You must be signed in to change notification settings - Fork 34
[interop] Add Support for Anonymous Declarations #434
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
[interop] Add Support for Anonymous Declarations #434
Conversation
web_generator/test/integration/interop_gen/ts_typing_input.d.ts
Outdated
Show resolved
Hide resolved
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.
Thanks, Nike! Just a couple more comments.
Sorry, GitHub UI is atrocious and didn't show me all the unresolved comments in the commits tab so I have a few 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.
Looks good! Just some small nits around prints.
# Conflicts: # web_generator/lib/src/ast/base.dart # web_generator/lib/src/ast/declarations.dart # web_generator/lib/src/interop_gen/transform/transformer.dart # web_generator/test/integration/interop_gen/project/output/c.dart
Fixes #385
Fixes #422
Fixes #410
Fixes #433
This PR adds support for generating declarations for anonymous declarations, such as anonymous objects, unions, closures and constructor types.
This PR also adds support for nullable types (types unioned with
undefined
and/ornull
).A hashing function is used for consistently hashing string objects, which is used for hashing identifiers for anonymous unions, objects and more, as well as comparing such names to allow reusing of such types.
string | number | boolean
may look like the following:JSTupleX
declaration generated depending on the number of members it may have (i.e if a 2 member tuple exists, it will be an instance ofJSTuple2<A, B>
). The tuple extension type looks like the following:call
. While Anonymous function types ((str: string) => void
) have theircall
implementations asexternal
, anonymous constructor types (new (str: string) => T
to constructT
) are implemented as function calls to create the given object. In the future after Make JSExportedDartFunction generic and add a toJSGeneric function sdk#54557, we should be able to replace this with a genericJSFunction
.