isType<Type>(type: Type): (<Actual>(input: Actual | TypeOfMap[Type]) => input is TypeOfMap[Type])
Takes a type string and checks if given input is of that typeof. This
"patches" typeof so null is not "object" but "null" instead (rejected
proposal for lack of backwards compatibility, more details
here).
Example
constisString = isType("string");
isString("value"); // true isString(1); // false
Returns
Curried function with type in context that returns true if
input is of typeoftype, false otherwise.
Type Parameters
Type extends keyof TypeOfMap
Parameters
type: Type
Returns (<Actual>(input: Actual | TypeOfMap[Type]) => input is TypeOfMap[Type])
<Actual>(input: Actual | TypeOfMap[Type]): input is TypeOfMap[Type]
Takes a
type
string and checks if giveninput
is of thattypeof
. This "patches" typeof sonull
is not"object"
but"null"
instead (rejected proposal for lack of backwards compatibility, more details here).Example
Returns
Curried function with
type
in context that returnstrue
ifinput
is oftypeof
type
,false
otherwise.