You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, importing JavaScript APIs from the global scope requires users to write TypeScript declaration files and import APIs through the standard BridgeJS workflow. For simple use cases where users only need to access a few well-known global APIs like console.log() or document.getElementById(), this approach can feel heavyweight and requires additional setup steps.
Proposed Solution
Allow users to declare global scope imports directly in Swift using @JS var declarations with protocol interfaces, eliminating the need for separate .d.ts files for simple global API access.
This feature would require adding a macro plugin to support @JS var [name]: [Type] declarations that generates getter/setter accessors interacting with the code generated by @JS protocol
If it works well, we might be able to make ImportTS just to generate @JS annotated Swift code and centralize ABI-facing code in ExportSwift
Motivation
Currently, importing JavaScript APIs from the global scope requires users to write TypeScript declaration files and import APIs through the standard BridgeJS workflow. For simple use cases where users only need to access a few well-known global APIs like
console.log()ordocument.getElementById(), this approach can feel heavyweight and requires additional setup steps.Proposed Solution
Allow users to declare global scope imports directly in Swift using
@JS vardeclarations with protocol interfaces, eliminating the need for separate.d.tsfiles for simple global API access.High-level API
Implementation
This feature would require adding a macro plugin to support
@JS var [name]: [Type]declarations that generates getter/setter accessors interacting with the code generated by@JS protocolIf it works well, we might be able to make ImportTS just to generate
@JSannotated Swift code and centralize ABI-facing code in ExportSwift