From 9803253363105c6b0ae6f7651fc8ec11c90b14b1 Mon Sep 17 00:00:00 2001 From: David Laban Date: Mon, 7 Jan 2019 14:53:01 +0000 Subject: [PATCH] flow type update: babel-types.isType(?string, string): boolean (#9275) --- packages/babel-types/src/validators/isType.js | 2 +- packages/babel-types/test/validators.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/babel-types/src/validators/isType.js b/packages/babel-types/src/validators/isType.js index 6b5e0feade..cf9a681a0a 100644 --- a/packages/babel-types/src/validators/isType.js +++ b/packages/babel-types/src/validators/isType.js @@ -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 diff --git a/packages/babel-types/test/validators.js b/packages/babel-types/test/validators.js index 4b59edeb27..ce47402881 100644 --- a/packages/babel-types/test/validators.js +++ b/packages/babel-types/test/validators.js @@ -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); + }); }); });