-
Notifications
You must be signed in to change notification settings - Fork 39
[interop] Add support for destructured parameters #469
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
base: main
Are you sure you want to change the base?
Conversation
Added support for working with destructured parameters, as well as other kind of parameters. These take the place of the param type, since destructuring in parameters is not allowed in Dart. However, this goes a step further and provides documentation on the parameter itself, providing the form of the param as documentation. Signed-off-by: Nike Okoronkwo <[email protected]>
external double firstTwoNumbers( | ||
|
||
/// Parameter is of the form: [a, b] | ||
_i1.JSArray<_i1.JSNumber> arr117); |
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.
Can this not be a JSTuple$N
type?
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.
Yes it could, but the user may be interfacing with an API that sends down some data in a certain format, and [number, number] !== number[]
.
({ a: number } | { b: string }) & | ||
({ c: boolean } | ({ d: bigint } & { e: symbol })); | ||
export declare function firstTwoNumbers([a, b]: number[]): number; | ||
export declare function productInfo({ name, id }: Product, options?: { search?: boolean, showId?: boolean }): string; |
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.
Interesting! What is the purpose of this? Is it saying "I don't care about any values besides name and id"?
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.
Yes.
The user may just care about only the name and id (the purpose of normal destructuring).
(it would be nice to have something like this in Dart)
Added support for working with destructured parameters, as well as other kind of parameters. These take the place of the param type, since destructuring in parameters is not allowed in Dart.
However, this goes a step further and provides documentation on the parameter itself, providing the form of the param as documentation.