Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(napi): validate fn for Option<T> #1223

Merged
merged 1 commit into from
Jul 6, 2022
Merged

Conversation

Brooooooklyn
Copy link
Sponsor Member

@Brooooooklyn Brooooooklyn merged commit 1ac7fcf into main Jul 6, 2022
@Brooooooklyn Brooooooklyn deleted the strict-check-optional branch July 6, 2022 06:34
@Hywan
Copy link
Contributor

Hywan commented Jul 7, 2022

Passing undefined for an Option<String> produces the following error:

Expect value to be Option<String>, but received Undefined

If we pass null, it works. The goal of Option<T> is to have optional parameter, kind of, so passing null doesn't help :-). Is it possible to treat undefined as a valid None equivalent?

Edit: since null and undefined are supported in FromNapiValue and ToNapiValue in Option<T> implementations, I took the liberty to open a PR, #1228 to update its ValidateNapiValue implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NAPI doesn't check for types received by a function
2 participants