check
Create a strictly typed TypeObject.
type.check(Type)
Given a type, returns a TypeObject that will check values against that type. Throws if another type is provided as a value.
import { Reflect, type } from "can/everything";
let val = Reflect.convert(new Date(), type.check(Date));
console.log(val); // Date()
Reflect.convert("12/14/1933", type.check(Date));
// throws for providing an invalid type.
Parameters
- Type
{function}
:A constructor function that values will be checked against.