Skip to content

Commit

Permalink
Build InterfaceTypeAnnotation generated type code (babel#7982)
Browse files Browse the repository at this point in the history
  • Loading branch information
jridgewell authored May 18, 2018
1 parent 27c39c5 commit 0200a3e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/babel-types/src/asserts/generated/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,12 @@ export function assertInterfaceDeclaration(
): void {
assert("InterfaceDeclaration", node, opts);
}
export function assertInterfaceTypeAnnotation(
node: Object,
opts?: Object = {},
): void {
assert("InterfaceTypeAnnotation", node, opts);
}
export function assertIntersectionTypeAnnotation(
node: Object,
opts?: Object = {},
Expand Down
4 changes: 4 additions & 0 deletions packages/babel-types/src/builders/generated/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,10 @@ export function InterfaceDeclaration(...args: Array<any>): Object {
return builder("InterfaceDeclaration", ...args);
}
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 {
return builder("IntersectionTypeAnnotation", ...args);
}
Expand Down
19 changes: 19 additions & 0 deletions packages/babel-types/src/validators/generated/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1387,6 +1387,23 @@ export function isInterfaceDeclaration(node: Object, opts?: Object): boolean {

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(
node: Object,
opts?: Object,
Expand Down Expand Up @@ -3840,6 +3857,7 @@ export function isFlow(node: Object, opts?: Object): boolean {
"InferredPredicate" === nodeType ||
"InterfaceExtends" === nodeType ||
"InterfaceDeclaration" === nodeType ||
"InterfaceTypeAnnotation" === nodeType ||
"IntersectionTypeAnnotation" === nodeType ||
"MixedTypeAnnotation" === nodeType ||
"EmptyTypeAnnotation" === nodeType ||
Expand Down Expand Up @@ -3892,6 +3910,7 @@ export function isFlowType(node: Object, opts?: Object): boolean {
"ExistsTypeAnnotation" === nodeType ||
"FunctionTypeAnnotation" === nodeType ||
"GenericTypeAnnotation" === nodeType ||
"InterfaceTypeAnnotation" === nodeType ||
"IntersectionTypeAnnotation" === nodeType ||
"MixedTypeAnnotation" === nodeType ||
"EmptyTypeAnnotation" === nodeType ||
Expand Down

0 comments on commit 0200a3e

Please sign in to comment.