Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e174c60

Browse files
committedMay 1, 2025··
Use JSValue instead for JSPromise's closure return types
Returning `some ConvertibleToJSValue` was not consistent with `JSClosure` initializers, which always return `JSValue`. Also it emits `Capture of non-sendable type '(some ConvertibleToJSValue).Type' in an isolated closure` for some reasons.
1 parent 84af891 commit e174c60

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed
 

‎Sources/JavaScriptKit/BasicObjects/JSPromise.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public final class JSPromise: JSBridgedClass {
9898
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
9999
@discardableResult
100100
public func then(
101-
success: sending @escaping (sending JSValue) async throws -> some ConvertibleToJSValue
101+
success: sending @escaping (sending JSValue) async throws -> JSValue
102102
) -> JSPromise {
103103
let closure = JSOneshotClosure.async {
104104
try await success($0[0]).jsValue
@@ -127,8 +127,8 @@ public final class JSPromise: JSBridgedClass {
127127
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
128128
@discardableResult
129129
public func then(
130-
success: sending @escaping (sending JSValue) async throws -> some ConvertibleToJSValue,
131-
failure: sending @escaping (sending JSValue) async throws -> some ConvertibleToJSValue
130+
success: sending @escaping (sending JSValue) async throws -> JSValue,
131+
failure: sending @escaping (sending JSValue) async throws -> JSValue
132132
) -> JSPromise {
133133
let successClosure = JSOneshotClosure.async {
134134
try await success($0[0]).jsValue
@@ -158,7 +158,7 @@ public final class JSPromise: JSBridgedClass {
158158
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
159159
@discardableResult
160160
public func `catch`(
161-
failure: sending @escaping (sending JSValue) async throws -> some ConvertibleToJSValue
161+
failure: sending @escaping (sending JSValue) async throws -> JSValue
162162
) -> JSPromise {
163163
let closure = JSOneshotClosure.async {
164164
try await failure($0[0]).jsValue

0 commit comments

Comments
 (0)
Please sign in to comment.