Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions flow-typed/npm/babel-traverse_v7.x.x.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ declare module '@babel/traverse' {
create(
node: BabelNode,
obj: Array<BabelNode>,
key: string,
key: string | number,
listKey: string,
): NodePath<>;
maybeQueue(path: NodePath<>, notPriority?: boolean): void;
Expand Down Expand Up @@ -614,7 +614,7 @@ declare module '@babel/traverse' {
context: TraversalContext;
container: null | {...} | Array<{...}>;
listKey: null | string;
key: null | string;
key: null | string | number;

/* Declaring node as readonly isn't entirely correct since the node can be
* changed by e.g. calling replaceWith. However, this is needed to reasonably
Expand All @@ -637,7 +637,7 @@ declare module '@babel/traverse' {
parent: BabelNode,
container: null | {...} | Array<{...}>,
listKey: null | string,
key: null | string,
key: string | number,
}): NodePath<>;

getScope(scope: Scope): Scope;
Expand Down Expand Up @@ -964,10 +964,10 @@ declare module '@babel/traverse' {
parentPath: NodePath<>,
container: ?{...} | ?Array<{...}>,
listKey: string,
key: string,
key: string | number,
): void;

setKey(key: string): void;
setKey(key: string | number): void;

requeue(pathToQueue?: NodePath<>): void;

Expand Down Expand Up @@ -1013,7 +1013,7 @@ declare module '@babel/traverse' {

getCompletionRecords(): Array<NodePath<>>;

getSibling(key: string): NodePath<>;
getSibling(key: string | number): NodePath<>;

getPrevSibling(): NodePath<>;

Expand Down
25 changes: 25 additions & 0 deletions flow-typed/npm/babel-types_v7.x.x.js
Original file line number Diff line number Diff line change
Expand Up @@ -3252,6 +3252,24 @@ declare module "@babel/types" {
declare type BabelNodeTSBaseType = BabelNodeTSAnyKeyword | BabelNodeTSBooleanKeyword | BabelNodeTSBigIntKeyword | BabelNodeTSIntrinsicKeyword | BabelNodeTSNeverKeyword | BabelNodeTSNullKeyword | BabelNodeTSNumberKeyword | BabelNodeTSObjectKeyword | BabelNodeTSStringKeyword | BabelNodeTSSymbolKeyword | BabelNodeTSUndefinedKeyword | BabelNodeTSUnknownKeyword | BabelNodeTSVoidKeyword | BabelNodeTSThisType | BabelNodeTSTemplateLiteralType | BabelNodeTSLiteralType;
declare type BabelNodeModuleDeclaration = BabelNodeExportAllDeclaration | BabelNodeExportDefaultDeclaration | BabelNodeExportNamedDeclaration | BabelNodeImportDeclaration;

declare type BabelNodeValidator = {
(node?: BabelNode, key?: string | { toString(): string }, val?: unknown): void;
type?: 'string' | 'number' | 'bigint' | 'boolean' | 'symbol' | 'undefined' | 'object' | 'function' | 'array' | 'null' | 'any';
each?: BabelNodeValidator;
chainOf?: ReadonlyArray<BabelNodeValidator>;
oneOf?: ReadonlyArray<unknown>;
oneOfNodeTypes?: ReadonlyArray<string>;
oneOfNodeOrValueTypes?: ReadonlyArray<string>;
shapeOf?: { [field: string]: BabelNodeFieldOptions };
};

declare type BabelNodeFieldOptions = {
default?: string | number | boolean | [] | null;
optional?: boolean;
deprecated?: boolean;
validate?: BabelNodeValidator;
};

declare export function arrayExpression(elements?: Array<null | BabelNodeExpression | BabelNodeSpreadElement>): BabelNodeArrayExpression;
declare export function assignmentExpression(operator: string, left: BabelNodeLVal | BabelNodeOptionalMemberExpression, right: BabelNodeExpression): BabelNodeAssignmentExpression;
declare export function binaryExpression(operator: "+" | "-" | "/" | "%" | "*" | "**" | "&" | "|" | ">>" | ">>>" | "<<" | "^" | "==" | "===" | "!=" | "!==" | "in" | "instanceof" | ">" | "<" | ">=" | "<=" | "|>", left: BabelNodeExpression | BabelNodePrivateName, right: BabelNodeExpression): BabelNodeBinaryExpression;
Expand Down Expand Up @@ -4189,4 +4207,11 @@ declare module "@babel/types" {
declare export type TSType = BabelNodeTSType;
declare export type TSBaseType = BabelNodeTSBaseType;
declare export type ModuleDeclaration = BabelNodeModuleDeclaration;
declare export var VISITOR_KEYS: { [type: string]: Array<string> };
declare export var ALIAS_KEYS: { [type: BabelNode['type']]: Array<string> };
declare export var FLIPPED_ALIAS_KEYS: { [alias: string]: Array<BabelNode['type']> };
declare export var NODE_FIELDS: { [type: string]: { [field: string]: BabelNodeFieldOptions } };
declare export var BUILDER_KEYS: { [type: string]: Array<string> };
declare export var DEPRECATED_KEYS: { [type: string]: BabelNode['type'] };
declare export var TYPES: Array<string>;
}
30 changes: 30 additions & 0 deletions scripts/support/generateBabelTypesFlowLibraryDefinition.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,36 @@ function main() {
),
);

// definitions/
typeDecls += `
declare type ${NODE_PREFIX}Validator = {
(node?: ${NODE_PREFIX}, key?: string | { toString(): string }, val?: unknown): void;
type?: 'string' | 'number' | 'bigint' | 'boolean' | 'symbol' | 'undefined' | 'object' | 'function' | 'array' | 'null' | 'any';
each?: ${NODE_PREFIX}Validator;
chainOf?: ReadonlyArray<${NODE_PREFIX}Validator>;
oneOf?: ReadonlyArray<unknown>;
oneOfNodeTypes?: ReadonlyArray<string>;
oneOfNodeOrValueTypes?: ReadonlyArray<string>;
shapeOf?: { [field: string]: ${NODE_PREFIX}FieldOptions };
};

declare type ${NODE_PREFIX}FieldOptions = {
default?: string | number | boolean | [] | null;
optional?: boolean;
deprecated?: boolean;
validate?: ${NODE_PREFIX}Validator;
};
`;
lines.push(
`declare export var VISITOR_KEYS: { [type: string]: Array<string> };`,
`declare export var ALIAS_KEYS: { [type: ${NODE_PREFIX}['type']]: Array<string> };`,
`declare export var FLIPPED_ALIAS_KEYS: { [alias: string]: Array<${NODE_PREFIX}['type']> };`,
`declare export var NODE_FIELDS: { [type: string]: { [field: string]: ${NODE_PREFIX}FieldOptions } };`,
`declare export var BUILDER_KEYS: { [type: string]: Array<string> };`,
`declare export var DEPRECATED_KEYS: { [type: string]: ${NODE_PREFIX}['type'] };`,
`declare export var TYPES: Array<string>;`,
);

// Node type declarations, kept module-local. The exported aliases and
// function signatures below reference them by their `BabelNode`-prefixed name.
const moduleInner = typeDecls + '\n' + lines.join('\n');
Expand Down
Loading