diff --git a/Sources/JavaScriptKit/JSValueConvertible.swift b/Sources/JavaScriptKit/JSValueConvertible.swift index eb1d43ab..870820da 100644 --- a/Sources/JavaScriptKit/JSValueConvertible.swift +++ b/Sources/JavaScriptKit/JSValueConvertible.swift @@ -29,17 +29,19 @@ public protocol JSValueDecodable { public typealias JSValueCodable = JSValueEncodable & JSValueDecodable -extension JSBridgedType { - public static func canDecode(from jsValue: JSValue) -> Bool { - jsValue.isInstanceOf(Self.classRef) - } - +extension JSAbstractBridgedType { public init(jsValue: JSValue) { self.init(objectRef: jsValue.object!) } public func jsValue() -> JSValue { - return JSValue.object(objectRef) + .object(objectRef) + } +} + +extension JSBridgedType { + public static func canDecode(from jsValue: JSValue) -> Bool { + jsValue.isInstanceOf(Self.classRef) } } diff --git a/Sources/JavaScriptKit/Support.swift b/Sources/JavaScriptKit/Support.swift index 5c0df905..d76881d0 100644 --- a/Sources/JavaScriptKit/Support.swift +++ b/Sources/JavaScriptKit/Support.swift @@ -217,7 +217,7 @@ public struct AnyJSValueCodable: JSValueCodable, ExpressibleByNilLiteral { } } -public func staticCast(_ ref: JSBridgedType) -> Type { +public func staticCast(_ ref: JSAbstractBridgedType) -> Type { return Type(objectRef: ref.objectRef) }