Skip to content

Commit

Permalink
Remove TSPropertySignature.initializer (#16154)
Browse files Browse the repository at this point in the history
Co-authored-by: Babel Bot <30521560+liuxingbaoyu@users.noreply.github.com>
  • Loading branch information
fisker and liuxingbaoyu committed Dec 11, 2023
1 parent 93dd407 commit e9a74bc
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 13 deletions.
8 changes: 1 addition & 7 deletions packages/babel-generator/src/generators/typescript.ts
Expand Up @@ -120,19 +120,13 @@ export function TSPropertySignature(
this: Printer,
node: t.TSPropertySignature,
) {
const { readonly, initializer } = node;
const { readonly } = node;
if (readonly) {
this.word("readonly");
this.space();
}
this.tsPrintPropertyOrMethodName(node);
this.print(node.typeAnnotation, node);
if (initializer) {
this.space();
this.token("=");
this.space();
this.print(initializer, node);
}
this.token(";");
}

Expand Down
1 change: 0 additions & 1 deletion packages/babel-parser/src/types.d.ts
Expand Up @@ -1345,7 +1345,6 @@ export interface TsPropertySignature extends TsNamedTypeElementBase {
type: "TSPropertySignature";
readonly?: true;
typeAnnotation?: TsTypeAnnotation;
initializer?: Expression;
}

export interface TsMethodSignature
Expand Down
@@ -0,0 +1 @@
interface I { x: number = 1;}
@@ -0,0 +1,3 @@
{
"throws": "Unexpected token, expected \";\" (1:24)"
}
1 change: 0 additions & 1 deletion packages/babel-types/src/ast-types/generated/index.ts
Expand Up @@ -1742,7 +1742,6 @@ export interface TSPropertySignature extends BaseNode {
type: "TSPropertySignature";
key: Expression;
typeAnnotation?: TSTypeAnnotation | null;
initializer?: Expression | null;
computed?: boolean;
kind: "get" | "set";
optional?: boolean | null;
Expand Down
2 changes: 0 additions & 2 deletions packages/babel-types/src/builders/generated/index.ts
Expand Up @@ -1968,13 +1968,11 @@ export { tsConstructSignatureDeclaration as tSConstructSignatureDeclaration };
export function tsPropertySignature(
key: t.Expression,
typeAnnotation: t.TSTypeAnnotation | null = null,
initializer: t.Expression | null = null,
): t.TSPropertySignature {
return validateNode<t.TSPropertySignature>({
type: "TSPropertySignature",
key,
typeAnnotation,
initializer,
kind: null,
});
}
Expand Down
3 changes: 1 addition & 2 deletions packages/babel-types/src/definitions/typescript.ts
Expand Up @@ -127,12 +127,11 @@ const namedTypeElementCommon = () => ({

defineType("TSPropertySignature", {
aliases: ["TSTypeElement"],
visitor: ["key", "typeAnnotation", "initializer"],
visitor: ["key", "typeAnnotation"],
fields: {
...namedTypeElementCommon(),
readonly: validateOptional(bool),
typeAnnotation: validateOptionalType("TSTypeAnnotation"),
initializer: validateOptionalType("Expression"),
kind: {
validate: assertOneOf("get", "set"),
},
Expand Down

0 comments on commit e9a74bc

Please sign in to comment.