Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions web_generator/lib/src/translator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -992,10 +992,15 @@ class Translator {
final typeArguments = <code.TypeReference>[];
if (typeParameter != null &&
(dartType == 'JSArray' || dartType == 'JSPromise')) {
typeArguments.add(
_typeReference(typeParameter, onlyEmitInteropTypes: true),
);
// Issue #397: JSVoid does not extend JSAny, so it must not be used
// as a type argument (e.g. Promise<void> → JSPromise).
if (typeParameter.type != 'JSVoid') {
typeArguments.add(
_typeReference(typeParameter, onlyEmitInteropTypes: true),
);
}
}

final url = _urlForType(dartType);
return code.TypeReference(
(b) => b
Expand Down
3 changes: 3 additions & 0 deletions web_generator/test/integration/idl/methods_input.idl
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ interface Button {
undefined setDimensions(Dimensions size);
undefined setDimensions(unsigned long width, unsigned long height);
};
interface VoidPromiseTest {
Promise<void> doSomething();
};
Comment on lines +35 to +37
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

While adding this test case for Promise<void> is a good step, the corresponding expected output file web_generator/test/integration/idl/methods_expected.dart has not been updated to include the generated code for the VoidPromiseTest interface. This will likely cause the integration test to fail. Please update the expected output file to reflect the changes from this new test case.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the catch! I have updated the expected output file to include the generated bindings for VoidPromiseTest, matching the new Promise test case.