Check if t.is is already defined (specifically accounting for the isImmutable method in validators

This commit is contained in:
Henry Zhu 2016-04-16 18:27:55 -04:00
parent c9e5da6ad0
commit 6f5e47eff0

View File

@ -12,9 +12,12 @@ let t = exports;
*/
function registerType(type: string) {
let is = t[`is${type}`] = function (node, opts) {
return t.is(type, node, opts);
};
let is = t[`is${type}`];
if (!is) {
is = t[`is${type}`] = function (node, opts) {
return t.is(type, node, opts);
};
}
t[`assert${type}`] = function (node, opts) {
opts = opts || {};