Adding expectBigIntOrNumber() to TypeValidator
@@ -21,6 +21,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import static com.google.javascript.rhino.jstype.JSTypeNative.ARRAY_TYPE;
import static com.google.javascript.rhino.jstype.JSTypeNative.ASYNC_GENERATOR_TYPE;
+import static com.google.javascript.rhino.jstype.JSTypeNative.BIGINT_NUMBER;
import static com.google.javascript.rhino.jstype.JSTypeNative.BOOLEAN_TYPE;
import static com.google.javascript.rhino.jstype.JSTypeNative.GENERATOR_TYPE;
import static com.google.javascript.rhino.jstype.JSTypeNative.ITERABLE_TYPE;
@@ -479,6 +480,12 @@ class TypeValidator implements Serializable {
}
}
+ void expectBigIntOrNumber(Node n, JSType type, String msg) {
+ if (!type.isSubtypeOf(getNativeType(BIGINT_NUMBER))) {
+ mismatch(n, msg, type, getNativeType(BIGINT_NUMBER));
+ }
+ }
+
/**
* Expect the type to be anything but the null or void type. If the expectation is not met, issue
* a warning at the provided node's source code position. Note that a union type that includes the
