Skip to content

Commit

Permalink
fix missing typescript/flow types for babel-types
Browse files Browse the repository at this point in the history
  • Loading branch information
tanhauhau committed Jun 15, 2019
1 parent 6ae7efc commit 4b39d4b
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 4 deletions.
26 changes: 25 additions & 1 deletion packages/babel-types/scripts/generators/flow.js
Expand Up @@ -99,6 +99,14 @@ for (const type in t.NODE_FIELDS) {
", "
)}): ${NODE_PREFIX}${type};`
);
} else {
const functionName = toFunctionName(type);
lines.push(
`declare function _${functionName}(${args.join(
", "
)}): ${NODE_PREFIX}${type};`,
`declare export { _${functionName} as ${functionName} }`
);
}
}

Expand Down Expand Up @@ -131,7 +139,23 @@ lines.push(
exit?: TraversalHandler<T>,
};`.replace(/(^|\n) {2}/g, "$1"),
// eslint-disable-next-line
`declare function traverse<T>(n: BabelNode, TraversalHandler<T> | TraversalHandlers<T>, state?: T): void;`
`declare function traverse<T>(n: BabelNode, TraversalHandler<T> | TraversalHandlers<T>, state?: T): void;`,
`declare function is(type: string, n: BabelNode, opts: Object): boolean;`,
`declare function isBinding(node: BabelNode, parent: BabelNode, grandparent?: BabelNode): boolean`,
`declare function isBlockScoped(node: BabelNode): boolean`,
`declare function isImmutable(node: BabelNode): boolean`,
`declare function isLet(node: BabelNode): boolean`,
`declare function isNode(node: ?object): boolean`,
`declare function isNodesEquivalent(a: any, b: any): boolean`,
`declare function isPlaceholderType(placeholderType: ?string, targetType: string): boolean`,
`declare function isReferenced(node: BabelNode, parent: BabelNode, grandparent?: BabelNode): boolean`,
`declare function isScope(node: BabelNode, parent: BabelNode): boolean`,
`declare function isSpecifierDefault(specifier: BabelNodeModuleSpecifier): boolean`,
`declare function isType(nodetype: ?string, targetType: string): boolean`,
`declare function isValidES3Identifier(name: string): boolean`,
`declare function isValidES3Identifier(name: string): boolean`,
`declare function isValidIdentifier(name: string): boolean`,
`declare function isVar(node: BabelNode): boolean`
);

for (const type in t.FLIPPED_ALIAS_KEYS) {
Expand Down
23 changes: 20 additions & 3 deletions packages/babel-types/scripts/generators/typescript.js
Expand Up @@ -101,9 +101,10 @@ for (const type in t.NODE_FIELDS) {
`export function ${toFunctionName(type)}(${args.join(", ")}): ${type};`
);
} else {
const functionName = toFunctionName(type);
lines.push(
`declare function _${toFunctionName(type)}(${args.join(", ")}): ${type};`,
`export { _${toFunctionName(type)} as ${toFunctionName(type)}}`
`declare function _${functionName}(${args.join(", ")}): ${type};`,
`export { _${functionName} as ${functionName}}`
);
}
}
Expand Down Expand Up @@ -147,7 +148,23 @@ lines.push(
exit?: TraversalHandler<T>,
};`.replace(/(^|\n) {2}/g, "$1"),
// eslint-disable-next-line
`export function traverse<T>(n: Node, h: TraversalHandler<T> | TraversalHandlers<T>, state?: T): void;`
`export function traverse<T>(n: Node, h: TraversalHandler<T> | TraversalHandlers<T>, state?: T): void;`,
`export function is(type: string, n: Node, opts: object): boolean;`,
`export function isBinding(node: Node, parent: Node, grandparent?: Node): boolean`,
`export function isBlockScoped(node: Node): boolean`,
`export function isImmutable(node: Node): boolean`,
`export function isLet(node: Node): boolean`,
`export function isNode(node: ?object): boolean`,
`export function isNodesEquivalent(a: any, b: any): boolean`,
`export function isPlaceholderType(placeholderType: ?string, targetType: string): boolean`,
`export function isReferenced(node: Node, parent: Node, grandparent?: Node): boolean`,
`export function isScope(node: Node, parent: Node): boolean`,
`export function isSpecifierDefault(specifier: ModuleSpecifier): boolean`,
`export function isType(nodetype: ?string, targetType: string): boolean`,
`export function isValidES3Identifier(name: string): boolean`,
`export function isValidES3Identifier(name: string): boolean`,
`export function isValidIdentifier(name: string): boolean`,
`export function isVar(node: Node): boolean`
);

for (const type in t.DEPRECATED_KEYS) {
Expand Down

0 comments on commit 4b39d4b

Please sign in to comment.