flow type update: babel-types.isType(?string, string): boolean (#9275)
This commit is contained in:
parent
a55382e4ad
commit
9803253363
@ -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
|
||||
|
||||
@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user