Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: definition of TS function type params #15867

Merged
merged 1 commit into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 15 additions & 5 deletions packages/babel-types/src/ast-types/generated/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1718,14 +1718,14 @@ export interface TSQualifiedName extends BaseNode {
export interface TSCallSignatureDeclaration extends BaseNode {
type: "TSCallSignatureDeclaration";
typeParameters?: TSTypeParameterDeclaration | null;
parameters: Array<Identifier | RestElement>;
parameters: Array<ArrayPattern | Identifier | ObjectPattern | RestElement>;
typeAnnotation?: TSTypeAnnotation | null;
}

export interface TSConstructSignatureDeclaration extends BaseNode {
type: "TSConstructSignatureDeclaration";
typeParameters?: TSTypeParameterDeclaration | null;
parameters: Array<Identifier | RestElement>;
parameters: Array<ArrayPattern | Identifier | ObjectPattern | RestElement>;
typeAnnotation?: TSTypeAnnotation | null;
}

Expand All @@ -1744,7 +1744,7 @@ export interface TSMethodSignature extends BaseNode {
type: "TSMethodSignature";
key: Expression;
typeParameters?: TSTypeParameterDeclaration | null;
parameters: Array<Identifier | RestElement>;
parameters: Array<ArrayPattern | Identifier | ObjectPattern | RestElement>;
typeAnnotation?: TSTypeAnnotation | null;
computed?: boolean;
kind: "method" | "get" | "set";
Expand Down Expand Up @@ -1818,14 +1818,14 @@ export interface TSThisType extends BaseNode {
export interface TSFunctionType extends BaseNode {
type: "TSFunctionType";
typeParameters?: TSTypeParameterDeclaration | null;
parameters: Array<Identifier | RestElement>;
parameters: Array<ArrayPattern | Identifier | ObjectPattern | RestElement>;
typeAnnotation?: TSTypeAnnotation | null;
}

export interface TSConstructorType extends BaseNode {
type: "TSConstructorType";
typeParameters?: TSTypeParameterDeclaration | null;
parameters: Array<Identifier | RestElement>;
parameters: Array<ArrayPattern | Identifier | ObjectPattern | RestElement>;
typeAnnotation?: TSTypeAnnotation | null;
abstract?: boolean | null;
}
Expand Down Expand Up @@ -2915,8 +2915,13 @@ export interface ParentMaps {
| ObjectMethod
| ObjectProperty
| RestElement
| TSCallSignatureDeclaration
| TSConstructSignatureDeclaration
| TSConstructorType
| TSDeclareFunction
| TSDeclareMethod
| TSFunctionType
| TSMethodSignature
| VariableDeclarator;
ArrayTypeAnnotation:
| ArrayTypeAnnotation
Expand Down Expand Up @@ -5626,8 +5631,13 @@ export interface ParentMaps {
| ObjectMethod
| ObjectProperty
| RestElement
| TSCallSignatureDeclaration
| TSConstructSignatureDeclaration
| TSConstructorType
| TSDeclareFunction
| TSDeclareMethod
| TSFunctionType
| TSMethodSignature
| VariableDeclarator;
ObjectProperty: ObjectExpression | ObjectPattern | RecordExpression;
ObjectTypeAnnotation:
Expand Down
20 changes: 15 additions & 5 deletions packages/babel-types/src/builders/generated/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1927,7 +1927,9 @@ export function tsQualifiedName(
export { tsQualifiedName as tSQualifiedName };
export function tsCallSignatureDeclaration(
typeParameters: t.TSTypeParameterDeclaration | null | undefined = null,
parameters: Array<t.Identifier | t.RestElement>,
parameters: Array<
t.ArrayPattern | t.Identifier | t.ObjectPattern | t.RestElement
>,
typeAnnotation: t.TSTypeAnnotation | null = null,
): t.TSCallSignatureDeclaration {
return validateNode<t.TSCallSignatureDeclaration>({
Expand All @@ -1940,7 +1942,9 @@ export function tsCallSignatureDeclaration(
export { tsCallSignatureDeclaration as tSCallSignatureDeclaration };
export function tsConstructSignatureDeclaration(
typeParameters: t.TSTypeParameterDeclaration | null | undefined = null,
parameters: Array<t.Identifier | t.RestElement>,
parameters: Array<
t.ArrayPattern | t.Identifier | t.ObjectPattern | t.RestElement
>,
typeAnnotation: t.TSTypeAnnotation | null = null,
): t.TSConstructSignatureDeclaration {
return validateNode<t.TSConstructSignatureDeclaration>({
Expand Down Expand Up @@ -1968,7 +1972,9 @@ export { tsPropertySignature as tSPropertySignature };
export function tsMethodSignature(
key: t.Expression,
typeParameters: t.TSTypeParameterDeclaration | null | undefined = null,
parameters: Array<t.Identifier | t.RestElement>,
parameters: Array<
t.ArrayPattern | t.Identifier | t.ObjectPattern | t.RestElement
>,
typeAnnotation: t.TSTypeAnnotation | null = null,
): t.TSMethodSignature {
return validateNode<t.TSMethodSignature>({
Expand Down Expand Up @@ -2078,7 +2084,9 @@ export function tsThisType(): t.TSThisType {
export { tsThisType as tSThisType };
export function tsFunctionType(
typeParameters: t.TSTypeParameterDeclaration | null | undefined = null,
parameters: Array<t.Identifier | t.RestElement>,
parameters: Array<
t.ArrayPattern | t.Identifier | t.ObjectPattern | t.RestElement
>,
typeAnnotation: t.TSTypeAnnotation | null = null,
): t.TSFunctionType {
return validateNode<t.TSFunctionType>({
Expand All @@ -2091,7 +2099,9 @@ export function tsFunctionType(
export { tsFunctionType as tSFunctionType };
export function tsConstructorType(
typeParameters: t.TSTypeParameterDeclaration | null | undefined = null,
parameters: Array<t.Identifier | t.RestElement>,
parameters: Array<
t.ArrayPattern | t.Identifier | t.ObjectPattern | t.RestElement
>,
typeAnnotation: t.TSTypeAnnotation | null = null,
): t.TSConstructorType {
return validateNode<t.TSConstructorType>({
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-types/src/definitions/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ defineType("TSQualifiedName", {
const signatureDeclarationCommon = () => ({
typeParameters: validateOptionalType("TSTypeParameterDeclaration"),
[process.env.BABEL_8_BREAKING ? "params" : "parameters"]: validateArrayOfType(
["Identifier", "RestElement"],
["ArrayPattern", "Identifier", "ObjectPattern", "RestElement"],
),
[process.env.BABEL_8_BREAKING ? "returnType" : "typeAnnotation"]:
validateOptionalType("TSTypeAnnotation"),
Expand Down