Skip to content

chore: resolve Object langAliases in function argument types#1908

Merged
yury-s merged 2 commits intomicrosoft:mainfrom
yury-s:api-generator-object-alias-in-fn-args
Apr 9, 2026
Merged

chore: resolve Object langAliases in function argument types#1908
yury-s merged 2 commits intomicrosoft:mainfrom
yury-s:api-generator-object-alias-in-fn-args

Conversation

@yury-s
Copy link
Copy Markdown
Member

@yury-s yury-s commented Apr 9, 2026

Summary

  • Have convertBuiltinType consult langAliases for inner Object types when no customType is set, so function-arg Objects (which createClassesAndEnums does not visit) get their Java name from the alias.
  • Drop the last hardcoded Object-related jsonPath in the generator (Screencast.start.options.onFrame -> Consumer<ScreencastFrame>).
  • Generated output is unchanged: with the new alias-java: ScreencastFrame upstream, Screencast.java still produces Consumer<ScreencastFrame>, just via the general 1-arg Promise function path instead of a one-off branch.

The remaining WebSocketRoute.onClose.handler -> BiConsumer<Integer, String> case is left in place — its arguments are nullable primitives, not Objects, so it can't be expressed as an Object alias and would need general 2-arg-function support to remove.

Inner Objects nested inside function-typed arguments are not visited
by createClassesAndEnums, so the api generator never set customType
for them and had to fall back to a hardcoded jsonPath switch (the
Screencast.start.onFrame -> Consumer<ScreencastFrame> case).

Have convertBuiltinType resolve the Java type name from the inner
Object's langAliases when no customType is set, and drop the hardcoded
onFrame case. This works once microsoft/playwright adds alias-java
for the onFrame Object (already proposed upstream).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@yury-s yury-s merged commit b01bf64 into microsoft:main Apr 9, 2026
19 of 24 checks passed
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