GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — BridgeJS: support imports of JS `Promise` as `async` Swift by MaxDesiatov · Pull Request #707 · swiftwasm/JavaScriptKit

Conversation

@MaxDesiatov

@MaxDesiatov MaxDesiatov commented Mar 23, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Supersedes #486.

Provides a motivating example with fetchWeatherData() test. The full end-to-end flow works:

  1. TypeScript interface WeatherData { temperature: number; description: string; humidity: number; };
  2. Function fetchWeatherData(city: string): Promise<WeatherData>;
  3. JS returns Promise.resolve({ temperature: 15.5, description: "Cloudy", humidity: 80 });
  4. Swift awaits and gets a typed WeatherData struct with .temperature, .description, .humidity properties;
  5. No Foundation, no Codable, no manual JSValue unwrapping for this and analogous functions backed by fetch(...).json().

Compatible with Embedded Swift.

Additionally, @JSFunction now supports async effects.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
MaxDesiatov and others added 3 commits March 23, 2026 23:10
@MaxDesiatov
BridgeJS: support imports of Promise JS as async Swift
ab19ba9
@MaxDesiatov
E2e testing of bridging Promise<interface> returns
d741dce
@MaxDesiatov
fix formatting
d0b207c
@MaxDesiatov
MaxDesiatov requested review from kateinoigakukun and krodak and removed request for kateinoigakukun March 23, 2026 23:15
@MaxDesiatov
MaxDesiatov marked this pull request as ready for review March 23, 2026 23:16
@MaxDesiatov
MaxDesiatov requested a review from kateinoigakukun March 23, 2026 23:16
@MaxDesiatov MaxDesiatov added enhancement New feature or request bridgejs labels Mar 23, 2026
@MaxDesiatov MaxDesiatov changed the title BridgeJS: support imports of Promise JS as async Swift BridgeJS: support imports of JS Promise as async Swift Mar 23, 2026
kateinoigakukun
kateinoigakukun reviewed Mar 24, 2026
View reviewed changes

@kateinoigakukun kateinoigakukun left a comment

Copy link
Copy Markdown
Member

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.

I think we need a different approach using JSTypedClosure to avoid the boxing

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@MaxDesiatov
JSTypedClosure-based approach
2b8bcaf
@MaxDesiatov MaxDesiatov added this to the BridgeJS 2026 Q1 (Post MVP) milestone Mar 24, 2026
MaxDesiatov added 5 commits March 24, 2026 12:31
@MaxDesiatov
Clean up BridgeJSLink
7864617
@MaxDesiatov
Fix missing import _Concurrency
0e84003
@MaxDesiatov
Fix formatting
3044b3a
@MaxDesiatov
Use JSTypedClosure without wrapping the result value
8d4472e
@MaxDesiatov
Merge branch 'main' into maxd/async-bridgejs
4244627
@MaxDesiatov
MaxDesiatov marked this pull request as draft March 24, 2026 15:00
@MaxDesiatov
MaxDesiatov removed the request for review from krodak March 24, 2026 15:00
@MaxDesiatov
Make closure parameters as sending
61fe95e
@MaxDesiatov
MaxDesiatov marked this pull request as ready for review March 24, 2026 16:51
@MaxDesiatov
MaxDesiatov requested review from kateinoigakukun and krodak March 24, 2026 16:51
@MaxDesiatov MaxDesiatov mentioned this pull request Mar 24, 2026
ImportTS: Promise-returning TS funcs -> async Swift #486
Closed
kateinoigakukun
kateinoigakukun reviewed Mar 25, 2026
View reviewed changes
Comment thread Tests/BridgeJSRuntimeTests/AsyncImportTests.swift
import Testing
import JavaScriptKit

@Suite struct AsyncImportTests {

@kateinoigakukun kateinoigakukun Mar 25, 2026

Copy link
Copy Markdown
Member

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 you follow the pattern we have in recent other suites like https://github.com/swiftwasm/JavaScriptKit/blob/main/Tests/BridgeJSRuntimeTests/ArraySupportTests.swift ?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@MaxDesiatov MaxDesiatov Mar 26, 2026

Copy link
Copy Markdown
Member Author

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 you elaborate? Which specific pattern are you referring to? I suppose that's not the use of XCTest?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@kateinoigakukun kateinoigakukun Mar 26, 2026

Copy link
Copy Markdown
Member

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.

I mean, I'd like to avoid adding more and more imports in prelude.mjs and want to split into separate file like this: https://github.com/swiftwasm/JavaScriptKit/blob/main/Tests/BridgeJSRuntimeTests/JavaScript/ArraySupportTests.mjs

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

MaxDesiatov reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@MaxDesiatov MaxDesiatov Mar 26, 2026

Copy link
Copy Markdown
Member Author

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.

Thanks, also addressed

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
kateinoigakukun
kateinoigakukun reviewed Mar 25, 2026
View reviewed changes
Comment thread Tests/BridgeJSRuntimeTests/AsyncImportTests.swift Resolved

Uh oh!

There was an error while loading. Please reload this page.

MaxDesiatov added 2 commits March 26, 2026 17:04
@MaxDesiatov
Check more stack ABI types
cdb8013
@MaxDesiatov
Add support for async in @JSFunction
695a715
MaxDesiatov and others added 6 commits March 26, 2026 19:46
@MaxDesiatov
Use namespaced import
67ff8e6
@MaxDesiatov
Fix missing fetchWeatherData
ae831f1
@MaxDesiatov
Bring back fetchWeatherData
a250ab3
@MaxDesiatov
Regenerate fetchWeatherData bridging code
6d36763
@kateinoigakukun
BridgeJS: Centralize closure sig collection in BridgeSkeletonWalker
b472133
@kateinoigakukun
BridgeJS: Stop spreading isAsync handling outside of CallJSEmission
14561d4
@kateinoigakukun
kateinoigakukun force-pushed the maxd/async-bridgejs branch from c8de4e0 to 14561d4 Compare March 26, 2026 21:02
kateinoigakukun added 3 commits March 26, 2026 21:05
@kateinoigakukun
BridgeJS: Remove error-prone default effects in thunk generation
4bfdfe7
@kateinoigakukun
BridgeJSLink: Centralize async handling in ImportedThunkBuilder
a03b585
@kateinoigakukun
BridgeJS: Remove reundant returnType from call family of methods in…
22e7434
… ImportedThunkBuilder
@kateinoigakukun
kateinoigakukun merged commit 7e242b0 into main Mar 27, 2026
12 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@kateinoigakukun
kateinoigakukun deleted the maxd/async-bridgejs branch March 27, 2026 09:09
This was referenced Sep 9, 2026
BridgeJS: Unify thunk argument preparation PassiveLogic/JavaScriptKit#22
Closed
BridgeJS: Unify thunk argument preparation #813
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@kateinoigakukun kateinoigakukun kateinoigakukun left review comments
@krodak krodak Awaiting requested review from krodak

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

bridgejs enhancement New feature or request

Projects

None yet

Milestone

BridgeJS 2026 Q1 (Post MVP)

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@MaxDesiatov @kateinoigakukun
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.