BridgeJS: support imports of JS `Promise` as `async` Swift by MaxDesiatov · Pull Request #707 · swiftwasm/JavaScriptKit
Supersedes #486.
Provides a motivating example with fetchWeatherData() test. The full end-to-end flow works:
- TypeScript
interface WeatherData { temperature: number; description: string; humidity: number; }; - Function
fetchWeatherData(city: string): Promise<WeatherData>; - JS returns
Promise.resolve({ temperature: 15.5, description: "Cloudy", humidity: 80 }); - Swift awaits and gets a typed
WeatherDatastruct with.temperature,.description,.humidityproperties; - No Foundation, no Codable, no manual
JSValueunwrapping for this and analogous functions backed byfetch(...).json().
Compatible with Embedded Swift.
Additionally, @JSFunction now supports async effects.