Skip to content

Commit 32538ec

Browse files
authored
Fix Optional implementation for ConstructibleFromJSValue (#238)
fix optional decode
1 parent 0a4cb16 commit 32538ec

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Sources/JavaScriptKit/ConvertibleToJSValue.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,10 @@ extension Optional: ConstructibleFromJSValue where Wrapped: ConstructibleFromJSV
131131
public static func construct(from value: JSValue) -> Self? {
132132
switch value {
133133
case .null, .undefined:
134-
return nil
134+
return .some(nil)
135135
default:
136-
return Wrapped.construct(from: value)
136+
guard let wrapped = Wrapped.construct(from: value) else { return nil }
137+
return .some(wrapped)
137138
}
138139
}
139140
}

0 commit comments

Comments
 (0)