@putout/plugin-convert-typeof-to-is-type
The
typeof
operator returns a string indicating the type of the unevaluated operand.(c) MDN
typeof
to is type
. Merged to @putout/plugin-types
.
Install
npm i @putout/plugin-convert-typeof-to-is-type -D
Rule
{
"rules": {
"convert-typeof-to-is-type": "on"
}
}
❌ Example of incorrect code
if (typeof a === 'boolean')
return x;
✅ Example of correct code
const isBool = (a) => typeof a === 'boolean';
if (isBool(a))
return x;
License
MIT