Skip to content

Conversation

@krodak
Copy link
Member

@krodak krodak commented Dec 22, 2025

Introduction

This PR extends support for default parameter values when exporting Swift functions and constructors to JavaScript/TypeScript using the BridgeJS plugin.

It adds ability to:

  • use struct as default parameter
  • use default parameters in struct init and methods

Additional Changes

Some minor refactor to DefaultValueGenerator was needed, it got refactored into DefaultValueUtils, moved outside of BridgeJSLink as it needs to be used in JSGlueGen.
I considered moving it to separate module, considered using BridgeJSUtilities too, but it would require dependency on BridgeJSSkeleton so probably not worth it.
I think I might eventually extract some StackBasedThunkBuilder after array implementation to extract some helper functionality and lowering / lifting from JSGlueGen for stack-based types, but let's see after Array implementation 😅
Hope this is ok enough for now, but I'm happy to extract this into separate file, module or use different approach.

@krodak krodak self-assigned this Dec 22, 2025
@krodak krodak merged commit 994ce01 into swiftwasm:main Dec 23, 2025
10 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