Skip to content

Conversation

nikeokoronkwo
Copy link
Collaborator

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.

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]>
@nikeokoronkwo nikeokoronkwo changed the title [interop] Added support for destructured parameters [interop] Add support for destructured parameters Sep 20, 2025
external double firstTwoNumbers(

/// Parameter is of the form: [a, b]
_i1.JSArray<_i1.JSNumber> arr117);
Copy link
Contributor

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?

Copy link
Collaborator Author

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;
Copy link
Contributor

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"?

Copy link
Collaborator Author

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants