Build InterfaceTypeAnnotation generated type code (#7982)

This commit is contained in:
Justin Ridgewell 2018-05-18 14:41:19 -04:00 committed by GitHub
parent 27c39c512d
commit 0200a3e510
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 0 deletions

View File

@ -414,6 +414,12 @@ export function assertInterfaceDeclaration(
): void { ): void {
assert("InterfaceDeclaration", node, opts); assert("InterfaceDeclaration", node, opts);
} }
export function assertInterfaceTypeAnnotation(
node: Object,
opts?: Object = {},
): void {
assert("InterfaceTypeAnnotation", node, opts);
}
export function assertIntersectionTypeAnnotation( export function assertIntersectionTypeAnnotation(
node: Object, node: Object,
opts?: Object = {}, opts?: Object = {},

View File

@ -393,6 +393,10 @@ export function InterfaceDeclaration(...args: Array<any>): Object {
return builder("InterfaceDeclaration", ...args); return builder("InterfaceDeclaration", ...args);
} }
export { InterfaceDeclaration as interfaceDeclaration }; export { InterfaceDeclaration as interfaceDeclaration };
export function InterfaceTypeAnnotation(...args: Array<any>): Object {
return builder("InterfaceTypeAnnotation", ...args);
}
export { InterfaceTypeAnnotation as interfaceTypeAnnotation };
export function IntersectionTypeAnnotation(...args: Array<any>): Object { export function IntersectionTypeAnnotation(...args: Array<any>): Object {
return builder("IntersectionTypeAnnotation", ...args); return builder("IntersectionTypeAnnotation", ...args);
} }

View File

@ -1387,6 +1387,23 @@ export function isInterfaceDeclaration(node: Object, opts?: Object): boolean {
return false; return false;
} }
export function isInterfaceTypeAnnotation(
node: Object,
opts?: Object,
): boolean {
if (!node) return false;
const nodeType = node.type;
if (nodeType === "InterfaceTypeAnnotation") {
if (typeof opts === "undefined") {
return true;
} else {
return shallowEqual(node, opts);
}
}
return false;
}
export function isIntersectionTypeAnnotation( export function isIntersectionTypeAnnotation(
node: Object, node: Object,
opts?: Object, opts?: Object,
@ -3840,6 +3857,7 @@ export function isFlow(node: Object, opts?: Object): boolean {
"InferredPredicate" === nodeType || "InferredPredicate" === nodeType ||
"InterfaceExtends" === nodeType || "InterfaceExtends" === nodeType ||
"InterfaceDeclaration" === nodeType || "InterfaceDeclaration" === nodeType ||
"InterfaceTypeAnnotation" === nodeType ||
"IntersectionTypeAnnotation" === nodeType || "IntersectionTypeAnnotation" === nodeType ||
"MixedTypeAnnotation" === nodeType || "MixedTypeAnnotation" === nodeType ||
"EmptyTypeAnnotation" === nodeType || "EmptyTypeAnnotation" === nodeType ||
@ -3892,6 +3910,7 @@ export function isFlowType(node: Object, opts?: Object): boolean {
"ExistsTypeAnnotation" === nodeType || "ExistsTypeAnnotation" === nodeType ||
"FunctionTypeAnnotation" === nodeType || "FunctionTypeAnnotation" === nodeType ||
"GenericTypeAnnotation" === nodeType || "GenericTypeAnnotation" === nodeType ||
"InterfaceTypeAnnotation" === nodeType ||
"IntersectionTypeAnnotation" === nodeType || "IntersectionTypeAnnotation" === nodeType ||
"MixedTypeAnnotation" === nodeType || "MixedTypeAnnotation" === nodeType ||
"EmptyTypeAnnotation" === nodeType || "EmptyTypeAnnotation" === nodeType ||