From 7aeb11b41ea6cdec2fe5994b4a32454876dba8b6 Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Fri, 27 Oct 2017 16:46:39 -0700 Subject: [PATCH] Return doc comment template for interfaces and method signatures --- src/services/jsDoc.ts | 4 +++- .../fourslash/docCommentTemplateInterfaces.ts | 23 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/docCommentTemplateInterfaces.ts diff --git a/src/services/jsDoc.ts b/src/services/jsDoc.ts index 49f13d0b4c3..0443a950e94 100644 --- a/src/services/jsDoc.ts +++ b/src/services/jsDoc.ts @@ -266,10 +266,12 @@ namespace ts.JsDoc { case SyntaxKind.FunctionDeclaration: case SyntaxKind.MethodDeclaration: case SyntaxKind.Constructor: - const { parameters } = commentOwner as FunctionDeclaration | MethodDeclaration | ConstructorDeclaration; + case SyntaxKind.MethodSignature: + const { parameters } = commentOwner as FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | MethodSignature; return { commentOwner, parameters }; case SyntaxKind.ClassDeclaration: + case SyntaxKind.InterfaceDeclaration: return { commentOwner }; case SyntaxKind.VariableStatement: { diff --git a/tests/cases/fourslash/docCommentTemplateInterfaces.ts b/tests/cases/fourslash/docCommentTemplateInterfaces.ts new file mode 100644 index 00000000000..2faf49351f2 --- /dev/null +++ b/tests/cases/fourslash/docCommentTemplateInterfaces.ts @@ -0,0 +1,23 @@ +/// + +/////*interfaceFoo*/ +////interface Foo { +//// /*propertybar*/ +//// bar: any; +//// +//// /*methodbaz*/ +//// baz(message: any): void; +////} + +verify.docCommentTemplateAt("interfaceFoo", /*expectedOffset*/ 8, +`/** + * + */`); + +verify.emptyDocCommentTemplateAt("propertybar"); + +verify.docCommentTemplateAt("methodbaz", /*expectedOffset*/ 12, + `/** + * + * @param message + */`); \ No newline at end of file