Skip to content

Commit df7ff62

Browse files
Keep JSClosure overloads as derepcated initializer
1 parent 4c9b876 commit df7ff62

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Sources/JavaScriptKit/FundamentalObjects/JSClosure.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,19 @@ public class JSClosure: JSOneshotClosure {
5656

5757
var isReleased: Bool = false
5858

59+
@available(*, deprecated, message: "This initializer will be removed in the next minor version update. Please use `init(_ body: @escaping ([JSValue]) -> JSValue)`")
60+
@_disfavoredOverload
61+
public init(_ body: @escaping ([JSValue]) -> ()) {
62+
super.init({
63+
body($0)
64+
return .undefined
65+
})
66+
}
67+
68+
public override init(_ body: @escaping ([JSValue]) -> JSValue) {
69+
super.init(body)
70+
}
71+
5972
public override func callAsFunction(this: JSObject? = nil, arguments: [ConvertibleToJSValue]) -> JSValue {
6073
try! invokeJSFunction(self, arguments: arguments, this: this)
6174
}

0 commit comments

Comments
 (0)