Skip to content

Commit

Permalink
Fix Optional implementation for ConstructibleFromJSValue (#238)
Browse files Browse the repository at this point in the history
fix optional decode
  • Loading branch information
omochi authored Apr 5, 2024
1 parent 0a4cb16 commit 32538ec
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Sources/JavaScriptKit/ConvertibleToJSValue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,10 @@ extension Optional: ConstructibleFromJSValue where Wrapped: ConstructibleFromJSV
public static func construct(from value: JSValue) -> Self? {
switch value {
case .null, .undefined:
return nil
return .some(nil)
default:
return Wrapped.construct(from: value)
guard let wrapped = Wrapped.construct(from: value) else { return nil }
return .some(wrapped)
}
}
}
Expand Down

0 comments on commit 32538ec

Please sign in to comment.