Closed
Description
Motivation
Throwing an exception when returning JsValue::undefined()
and JsValue::null()
doesn't make sense because only a local exception handler could have any idea what it means.
https://eslint.org/docs/rules/no-throw-literal
Proposed Solution
Return undefined
to JavaScript for JsValue::undefined()
and return null
to JavaScript for JsValue::null()
.
Also consider returning Symbol
to JavaScript for JsValue::symbol(description: Option<&str>)
.
Alternatives
Instead of throwing value types, wrap them in a JavaScript Error object as recommended at https://eslint.org/docs/rules/no-throw-literal.
That's a good solution for other literals, so I'll raise it as another feature request.
However, for undefined
and null
, the JavaScript normal behaviour is to return undefined
and null