diff --git a/tests/cases/conformance/jsdoc/returns.ts b/tests/cases/conformance/jsdoc/returns.ts new file mode 100644 index 00000000000..72cb4a6cb67 --- /dev/null +++ b/tests/cases/conformance/jsdoc/returns.ts @@ -0,0 +1,9 @@ +// @allowJs: true +// @filename: returns.js +// @out: dummy.js +/** + * @returns {string} This comment is not currently exposed + */ +function f() { + return ""; +} diff --git a/tests/cases/fourslash/jsDocFunctionSignatures10.ts b/tests/cases/fourslash/jsDocFunctionSignatures10.ts new file mode 100644 index 00000000000..60810c46e70 --- /dev/null +++ b/tests/cases/fourslash/jsDocFunctionSignatures10.ts @@ -0,0 +1,15 @@ +/// +// @allowJs: true +// @Filename: Foo.js +/////** +//// * Do some foo things +//// * @template T A Foolish template +//// * @param {T} x a parameter +//// */ +////function foo(x) { +////} +//// +////fo/**/o() + +goTo.marker(); +verify.quickInfoIs("function foo(x: T): void", "Do some foo things"); diff --git a/tests/cases/fourslash/jsDocFunctionSignatures11.ts b/tests/cases/fourslash/jsDocFunctionSignatures11.ts new file mode 100644 index 00000000000..26b2cda6d2a --- /dev/null +++ b/tests/cases/fourslash/jsDocFunctionSignatures11.ts @@ -0,0 +1,9 @@ +/// +// @allowJs: true +// @Filename: Foo.js +/////** +//// * @type {{ [name: string]: string; }} variables +//// */ +////const vari/**/ables = {}; +goTo.marker(); +verify.quickInfoIs("const variables: {\n [name: string]: string;\n}"); diff --git a/tests/cases/fourslash/jsDocFunctionSignatures12.ts b/tests/cases/fourslash/jsDocFunctionSignatures12.ts new file mode 100644 index 00000000000..29a8ac4caeb --- /dev/null +++ b/tests/cases/fourslash/jsDocFunctionSignatures12.ts @@ -0,0 +1,13 @@ + +/// +// @allowJs: true +// @Filename: Foo.js +/////** +//// * @param {{ stringProp: string, +//// * numProp: number }} o +//// */ +////function f1(o) { +//// o/**/; +////} +goTo.marker(); +verify.quickInfoIs("(parameter) o: any"); diff --git a/tests/cases/fourslash/jsDocFunctionSignatures2.ts b/tests/cases/fourslash/jsDocFunctionSignatures2.ts index 174ea7d6560..e6430cba5bd 100644 --- a/tests/cases/fourslash/jsDocFunctionSignatures2.ts +++ b/tests/cases/fourslash/jsDocFunctionSignatures2.ts @@ -9,4 +9,4 @@ //// f6('', /**/false) goTo.marker(); -verify.currentSignatureHelpIs('f6(p0: string, p1?: boolean): number') +verify.currentSignatureHelpIs('f6(arg0: string, arg1?: boolean): number') diff --git a/tests/cases/fourslash/jsDocFunctionSignatures5.ts b/tests/cases/fourslash/jsDocFunctionSignatures5.ts new file mode 100644 index 00000000000..08d0da990bc --- /dev/null +++ b/tests/cases/fourslash/jsDocFunctionSignatures5.ts @@ -0,0 +1,18 @@ +/// +// @allowJs: true +// @Filename: Foo.js + +/////** +//// * Filters a path based on a regexp or glob pattern. +//// * @param {String} basePath The base path where the search will be performed. +//// * @param {String} pattern A string defining a regexp of a glob pattern. +//// * @param {String} type The search pattern type, can be a regexp or a glob. +//// * @param {Object} options A object containing options to the search. +//// * @return {Array} A list containing the filtered paths. +//// */ +////function pathFilter(basePath, pattern, type, options){ +//////... +////} +////pathFilter(/**/'foo', 'bar', 'baz', {}); +goTo.marker(); +verify.currentSignatureHelpDocCommentIs("Filters a path based on a regexp or glob pattern."); diff --git a/tests/cases/fourslash/jsDocFunctionSignatures6.ts b/tests/cases/fourslash/jsDocFunctionSignatures6.ts new file mode 100644 index 00000000000..10b290d6d02 --- /dev/null +++ b/tests/cases/fourslash/jsDocFunctionSignatures6.ts @@ -0,0 +1,19 @@ +/// +// @allowJs: true +// @Filename: Foo.js +/////** +//// * @param {string} p1 - A string param +//// * @param {string?} p2 - An optional param +//// * @param {string} [p3] - Another optional param +//// * @param {string} [p4="test"] - An optional param with a default value +//// */ +////function f1(p1, p2, p3, p4){} +////f1(/*1*/'foo', /*2*/'bar', /*3*/'baz', /*4*/'qux'); +goTo.marker('1'); +verify.currentParameterHelpArgumentDocCommentIs("- A string param"); +goTo.marker('2'); +verify.currentParameterHelpArgumentDocCommentIs("- An optional param "); +goTo.marker('3'); +verify.currentParameterHelpArgumentDocCommentIs("- Another optional param"); +goTo.marker('4'); +verify.currentParameterHelpArgumentDocCommentIs("- An optional param with a default value"); diff --git a/tests/cases/fourslash/jsDocFunctionSignatures7.ts b/tests/cases/fourslash/jsDocFunctionSignatures7.ts new file mode 100644 index 00000000000..6bbb8a34dcc --- /dev/null +++ b/tests/cases/fourslash/jsDocFunctionSignatures7.ts @@ -0,0 +1,16 @@ +/// +// @allowJs: true +// @Filename: Foo.js +/////** +//// * @param {string} p0 +//// * @param {string} [p1] +//// */ +////function Test(p0, p1) { +//// this.P0 = p0; +//// this.P1 = p1; +////} +//// +//// +////var /**/test = new Test(""); +goTo.marker(); +verify.quickInfoIs('var test: {\n P0: string;\n P1: string;\n}'); diff --git a/tests/cases/fourslash/jsDocFunctionSignatures8.ts b/tests/cases/fourslash/jsDocFunctionSignatures8.ts new file mode 100644 index 00000000000..3dbe38e34df --- /dev/null +++ b/tests/cases/fourslash/jsDocFunctionSignatures8.ts @@ -0,0 +1,16 @@ +/// +// @allowJs: true +// @Filename: Foo.js +/////** +//// * Represents a person +//// * @constructor +//// * @param {string} name The name of the person +//// * @param {number} age The age of the person +//// */ +////function Person(name, age) { +//// this.name = name; +//// this.age = age; +////} +////var p = new Pers/**/on(); +goTo.marker(); +verify.quickInfoIs("function Person(name: string, age: number): void", "Represents a person"); diff --git a/tests/cases/fourslash/jsDocFunctionSignatures9.ts b/tests/cases/fourslash/jsDocFunctionSignatures9.ts new file mode 100644 index 00000000000..26361bfe106 --- /dev/null +++ b/tests/cases/fourslash/jsDocFunctionSignatures9.ts @@ -0,0 +1,22 @@ +/// +// @allowJs: true +// @Filename: Foo.js +/////** first line of the comment +//// +////third line */ +////function foo() {} +////foo/**/(); +goTo.marker(); +verify.verifyQuickInfoDisplayParts('function', + '', + { start: 63, length: 3 }, + [{"text": "function", "kind": "keyword"}, + {"text": " ", "kind": "space"}, + {"text": "foo", "kind": "functionName"}, + {"text": "(", "kind": "punctuation"}, + {"text": ")", "kind": "punctuation"}, + {"text": ":", "kind": "punctuation"}, + {"text": " ", "kind": "space"}, + {"text": "void", "kind": "keyword"} + ], + [{"text": "first line of the comment\n\nthird line ", "kind": "text"}]); diff --git a/tests/cases/fourslash/jsdocReturnsTag.ts b/tests/cases/fourslash/jsdocReturnsTag.ts new file mode 100644 index 00000000000..9203bd9e036 --- /dev/null +++ b/tests/cases/fourslash/jsdocReturnsTag.ts @@ -0,0 +1,17 @@ +/// +// @allowJs: true +// @Filename: dummy.js +/////** +//// * Find an item +//// * @template T +//// * @param {T[]} l +//// * @param {T} x +//// * @returns {?T} The names of the found item(s). +//// */ +////function find(l, x) { +////} +////find(''/**/); + +goTo.marker(); +verify.currentSignatureHelpIs("find(l: T[], x: T): T") +// There currently isn't a way to display the return tag comment