BridgeJS: Enforce throws(JSException) for @JS protocol properties#564
BridgeJS: Enforce throws(JSException) for @JS protocol properties#564krodak wants to merge 1 commit intoswiftwasm:mainfrom
Conversation
@krodak I'm tackling on it on my local branch, let's leave it as is for now. |
|
After chat with @kateinoigakukun we agreed to not pursue This PR (properties) and #563 (methods) were implemented to address consistency feedback from #560. After seeing the full picture - especially the setter method pattern for properties and questions about closures - we think the added complexity isn't worth it at this stage. For current use cases, the simpler non-throwing protocol API works fine.
We can revisit alignment later if needed, now with implementation there is an understanding what it would actually take in user-facing interface, so gonna be easier to decide later on. |
Overview
throws(JSException)on@JS protocolproperty getters, matching the import side (@JSGetter) behavior{ get set }properties no longer supported - use readonly getter + setter method patternTest updates
Protocol.swifttest input: Updated properties to{ get throws(JSException) }pattern with setter methodsExportAPITests.swift: UpdatedDataProcessorprotocol with new property patternDocumentation
Exporting-Swift-Protocols.mdwith new property pattern and examplesMotivation
This completes the work started in #563 which enforced
throws(JSException)on protocol methods. Properties now follow the same pattern, fully addressing the inconsistency between import and export sides.Notes
While working on this, I realized that removing the exception check condition in
ImportTS.swiftwould break the current closure implementation - non-throwing closures would fail to compile.Should we consider enforcing
throws(JSException)on all closures as well? It makes sense given they're calling into JavaScript which can always throw. I'd prefer to tackle that in a separate follow-up PR.