Skip to content

Commit

Permalink
std::nullopt and std::monostate should map to undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
zcbenz committed Sep 6, 2024
1 parent 5a1d8d8 commit 0e8500a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/std_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ struct Type<std::optional<T>> {
const std::optional<T>& value,
napi_value* result) {
if (!value)
return napi_get_null(env, result);
return napi_get_undefined(env, result);
return ConvertToNode(env, *value, result);
}
static std::optional<std::optional<T>> FromNode(napi_env env,
Expand Down Expand Up @@ -303,9 +303,9 @@ struct Type<std::variant<ArgTypes...>> {
// we consider the type accepting undefined/null.
template<>
struct Type<std::monostate> {
static constexpr const char* name = ""; // no name for monostate
static constexpr const char* name = "undefined";
static napi_status ToNode(napi_env env, std::monostate, napi_value* result) {
return napi_get_null(env, result);
return napi_get_undefined(env, result);
}
static inline std::optional<std::monostate> FromNode(napi_env env,
napi_value value) {
Expand Down

0 comments on commit 0e8500a

Please sign in to comment.