lib: improve the usage of TypeError[INVALID_ARG_TYPE]
The initials of expected
in TypeError[ERR_INVALID_ARG_TYPE]
are inconsistent.
This PR is to:
- Unify the initial usage of
TypeError[INVALID_ARG_TYPE]
- Add an argument check before construct an error
- Revise some inappropriate usage of
INVALID_ARG_TYPE
Fixes: https://github.com/nodejs/node/issues/16383
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
commit message follows commit guidelines
Affected core subsystem(s)
lib