diff --git a/packages/ts-morph/src/structurePrinters/class/GetAccessorDeclarationStructurePrinter.ts b/packages/ts-morph/src/structurePrinters/class/GetAccessorDeclarationStructurePrinter.ts index 5be2087fe..de6a53717 100644 --- a/packages/ts-morph/src/structurePrinters/class/GetAccessorDeclarationStructurePrinter.ts +++ b/packages/ts-morph/src/structurePrinters/class/GetAccessorDeclarationStructurePrinter.ts @@ -19,7 +19,8 @@ export class GetAccessorDeclarationStructurePrinter extends NodePrinter> | undefined) { + private printOverloads( + writer: CodeBlockWriter, + name: string | WriterFunction, + structures: ReadonlyArray> | undefined, + ) { if (structures == null || structures.length === 0) return; @@ -64,7 +69,7 @@ export class MethodDeclarationStructurePrinter extends NodePrinter) { + printOverload(writer: CodeBlockWriter, name: string | WriterFunction, structure: OptionalKind) { this.printLeadingTrivia(writer, structure); this.printHeader(writer, name, structure); writer.write(";"); @@ -73,7 +78,7 @@ export class MethodDeclarationStructurePrinter extends NodePrinter | OptionalKind, ) { this.factory.forJSDoc().printDocs(writer, structure.docs); @@ -81,7 +86,7 @@ export class MethodDeclarationStructurePrinter extends NodePrinter> { protected printTextInternal(writer: CodeBlockWriter, structure: OptionalKind) { writer.hangingIndent(() => { - writer.write(`${structure.name}: `); + this.printTextOrWriterFunc(writer, structure.name); + writer.write(": "); printTextFromStringOrWriter(writer, structure.initializer); }); } diff --git a/packages/ts-morph/src/structurePrinters/interface/MethodSignatureStructurePrinter.ts b/packages/ts-morph/src/structurePrinters/interface/MethodSignatureStructurePrinter.ts index eee24388b..f75a0b671 100644 --- a/packages/ts-morph/src/structurePrinters/interface/MethodSignatureStructurePrinter.ts +++ b/packages/ts-morph/src/structurePrinters/interface/MethodSignatureStructurePrinter.ts @@ -12,7 +12,7 @@ export class MethodSignatureStructurePrinter extends NodePrinter) { this.factory.forJSDoc().printDocs(writer, structure.docs); - writer.write(structure.name); + this.printTextOrWriterFunc(writer, structure.name); writer.conditionalWrite(structure.hasQuestionToken, "?"); this.factory.forTypeParameterDeclaration().printTextsWithBrackets(writer, structure.typeParameters); this.factory.forParameterDeclaration().printTextsWithParenthesis(writer, structure.parameters); diff --git a/packages/ts-morph/src/structurePrinters/interface/PropertySignatureStructurePrinter.ts b/packages/ts-morph/src/structurePrinters/interface/PropertySignatureStructurePrinter.ts index 587dcb0a0..a92acad27 100644 --- a/packages/ts-morph/src/structurePrinters/interface/PropertySignatureStructurePrinter.ts +++ b/packages/ts-morph/src/structurePrinters/interface/PropertySignatureStructurePrinter.ts @@ -13,7 +13,7 @@ export class PropertySignatureStructurePrinter extends NodePrinter) { this.factory.forJSDoc().printDocs(writer, structure.docs); this.factory.forModifierableNode().printText(writer, structure); - writer.write(structure.name); + this.printTextOrWriterFunc(writer, structure.name); writer.conditionalWrite(structure.hasQuestionToken, "?"); this.factory.forTypedNode(":").printText(writer, structure); // why would someone write an initializer? I guess let them do it... diff --git a/packages/ts-morph/src/structures/base/name/PropertyNameableNodeStructure.ts b/packages/ts-morph/src/structures/base/name/PropertyNameableNodeStructure.ts deleted file mode 100644 index 0f1d2cde8..000000000 --- a/packages/ts-morph/src/structures/base/name/PropertyNameableNodeStructure.ts +++ /dev/null @@ -1,3 +0,0 @@ -export interface PropertyNameableNodeStructure { - name?: string; -} diff --git a/packages/ts-morph/src/structures/base/name/PropertyNamedNodeStructure.ts b/packages/ts-morph/src/structures/base/name/PropertyNamedNodeStructure.ts index a640cb394..263674f8e 100644 --- a/packages/ts-morph/src/structures/base/name/PropertyNamedNodeStructure.ts +++ b/packages/ts-morph/src/structures/base/name/PropertyNamedNodeStructure.ts @@ -1,3 +1,5 @@ +import { WriterFunction } from "../../../types"; + export interface PropertyNamedNodeStructure { - name: string; + name: string | WriterFunction; } diff --git a/packages/ts-morph/src/structures/base/name/index.ts b/packages/ts-morph/src/structures/base/name/index.ts index 41a8c9bee..2da0d6e1a 100644 --- a/packages/ts-morph/src/structures/base/name/index.ts +++ b/packages/ts-morph/src/structures/base/name/index.ts @@ -3,5 +3,4 @@ export * from "./BindingNamedNodeStructure"; export * from "./ModuleNamedNodeStructure"; export * from "./NameableNodeStructure"; export * from "./NamedNodeStructure"; -export * from "./PropertyNameableNodeStructure"; export * from "./PropertyNamedNodeStructure";