mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-09 20:51:43 -06:00
Add more jsdoc tests
This commit is contained in:
parent
65d1079f8f
commit
b14d7c7ebb
9
tests/cases/conformance/jsdoc/returns.ts
Normal file
9
tests/cases/conformance/jsdoc/returns.ts
Normal file
@ -0,0 +1,9 @@
|
||||
// @allowJs: true
|
||||
// @filename: returns.js
|
||||
// @out: dummy.js
|
||||
/**
|
||||
* @returns {string} This comment is not currently exposed
|
||||
*/
|
||||
function f() {
|
||||
return "";
|
||||
}
|
||||
15
tests/cases/fourslash/jsDocFunctionSignatures10.ts
Normal file
15
tests/cases/fourslash/jsDocFunctionSignatures10.ts
Normal file
@ -0,0 +1,15 @@
|
||||
///<reference path="fourslash.ts" />
|
||||
// @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<T>(x: T): void", "Do some foo things");
|
||||
9
tests/cases/fourslash/jsDocFunctionSignatures11.ts
Normal file
9
tests/cases/fourslash/jsDocFunctionSignatures11.ts
Normal file
@ -0,0 +1,9 @@
|
||||
///<reference path="fourslash.ts" />
|
||||
// @allowJs: true
|
||||
// @Filename: Foo.js
|
||||
/////**
|
||||
//// * @type {{ [name: string]: string; }} variables
|
||||
//// */
|
||||
////const vari/**/ables = {};
|
||||
goTo.marker();
|
||||
verify.quickInfoIs("const variables: {\n [name: string]: string;\n}");
|
||||
13
tests/cases/fourslash/jsDocFunctionSignatures12.ts
Normal file
13
tests/cases/fourslash/jsDocFunctionSignatures12.ts
Normal file
@ -0,0 +1,13 @@
|
||||
|
||||
///<reference path="fourslash.ts" />
|
||||
// @allowJs: true
|
||||
// @Filename: Foo.js
|
||||
/////**
|
||||
//// * @param {{ stringProp: string,
|
||||
//// * numProp: number }} o
|
||||
//// */
|
||||
////function f1(o) {
|
||||
//// o/**/;
|
||||
////}
|
||||
goTo.marker();
|
||||
verify.quickInfoIs("(parameter) o: any");
|
||||
@ -9,4 +9,4 @@
|
||||
//// f6('', /**/false)
|
||||
|
||||
goTo.marker();
|
||||
verify.currentSignatureHelpIs('f6(p0: string, p1?: boolean): number')
|
||||
verify.currentSignatureHelpIs('f6(arg0: string, arg1?: boolean): number')
|
||||
|
||||
18
tests/cases/fourslash/jsDocFunctionSignatures5.ts
Normal file
18
tests/cases/fourslash/jsDocFunctionSignatures5.ts
Normal file
@ -0,0 +1,18 @@
|
||||
///<reference path="fourslash.ts" />
|
||||
// @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.");
|
||||
19
tests/cases/fourslash/jsDocFunctionSignatures6.ts
Normal file
19
tests/cases/fourslash/jsDocFunctionSignatures6.ts
Normal file
@ -0,0 +1,19 @@
|
||||
///<reference path="fourslash.ts" />
|
||||
// @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");
|
||||
16
tests/cases/fourslash/jsDocFunctionSignatures7.ts
Normal file
16
tests/cases/fourslash/jsDocFunctionSignatures7.ts
Normal file
@ -0,0 +1,16 @@
|
||||
///<reference path="fourslash.ts" />
|
||||
// @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}');
|
||||
16
tests/cases/fourslash/jsDocFunctionSignatures8.ts
Normal file
16
tests/cases/fourslash/jsDocFunctionSignatures8.ts
Normal file
@ -0,0 +1,16 @@
|
||||
///<reference path="fourslash.ts" />
|
||||
// @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");
|
||||
22
tests/cases/fourslash/jsDocFunctionSignatures9.ts
Normal file
22
tests/cases/fourslash/jsDocFunctionSignatures9.ts
Normal file
@ -0,0 +1,22 @@
|
||||
///<reference path="fourslash.ts" />
|
||||
// @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"}]);
|
||||
17
tests/cases/fourslash/jsdocReturnsTag.ts
Normal file
17
tests/cases/fourslash/jsdocReturnsTag.ts
Normal file
@ -0,0 +1,17 @@
|
||||
///<reference path="fourslash.ts" />
|
||||
// @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<T>(l: T[], x: T): T")
|
||||
// There currently isn't a way to display the return tag comment
|
||||
Loading…
x
Reference in New Issue
Block a user