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

Remove TSPropertySignature.initializer #16154

Merged
merged 6 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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
8 changes: 1 addition & 7 deletions packages/babel-generator/src/generators/typescript.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
interface I { x: number = 1;}
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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