medikoo / type

Runtime validation and processing of JavaScript types
ISC License
35 stars 4 forks source link

fix: cover isOptional case with return null #7

Closed borracciaBlu closed 1 year ago

codecov[bot] commented 1 year ago

Codecov Report

Merging #7 (9761b47) into main (50c31ad) will not change coverage. The diff coverage is n/a.

:exclamation: Current head 9761b47 differs from pull request most recent head ecc4d9a. Consider uploading reports for the commit ecc4d9a to get more accurate results

@@           Coverage Diff           @@
##             main       #7   +/-   ##
=======================================
  Coverage   95.02%   95.02%           
=======================================
  Files          58       58           
  Lines         603      603           
=======================================
  Hits          573      573           
  Misses         30       30           

:mega: Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

borracciaBlu commented 1 year ago

Hi @medikoo ,

I've just realised that the types were not covering the isOptional case...

isOptional - Makes null or undefined accepted as valid value. In such case instead of TypeError being thrown, null is returned.
default - A value to be returned if null or undefined is passed as an input value.

I've assumed that default will be forced of the same type of the ensure function. Let me know.