flow type update: babel-types.isType(?string, string): boolean (#9275)

This commit is contained in:
David Laban 2019-01-07 14:53:01 +00:00 committed by Brian Ng
parent a55382e4ad
commit 9803253363
2 changed files with 4 additions and 1 deletions

View File

@ -4,7 +4,7 @@ import { FLIPPED_ALIAS_KEYS, ALIAS_KEYS } from "../definitions";
/**
* Test if a `nodeType` is a `targetType` or if `targetType` is an alias of `nodeType`.
*/
export default function isType(nodeType: string, targetType: string): boolean {
export default function isType(nodeType: ?string, targetType: string): boolean {
if (nodeType === targetType) return true;
// This is a fast-path. If the test above failed, but an alias key is found, then the

View File

@ -136,5 +136,8 @@ describe("validators", function() {
it("returns false if nodeType and targetType are unrelated", function() {
expect(t.isType("ArrayExpression", "ClassBody")).toBe(false);
});
it("returns false if nodeType is undefined", function() {
expect(t.isType(undefined, "Expression")).toBe(false);
});
});
});