Skip to content

Type-checking when getting values #191

@jasongin

Description

@jasongin

There were a few questions in the PR about whether we need to check the type of a value before getting a casted value. For example, in napi_get_value_int32 we check value->IsNumber(), then call value.As<v8::Int32>()->Value(). What if the value is a non-integer number? Does the As<> cast work, or crash, or what?

Basically we need to add a bunch of test cases for these kinds of conversions, and add necessary type checks to avoid crashes. In my opinion, the APIs should not crash when provided a napi_value that is valid but the wrong type.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions