diff --git a/tests/cases/conformance/jsdoc/callbackTag1.ts b/tests/cases/conformance/jsdoc/callbackTag1.ts new file mode 100644 index 00000000000..e97cd23921b --- /dev/null +++ b/tests/cases/conformance/jsdoc/callbackTag1.ts @@ -0,0 +1,12 @@ +// @noEmit: true +// @allowJs: true +// @checkJs: true +// @Filename: cb.js + +/** @callback Sid + * @param {string} s + * @returns {string} What were you expecting + */ + +/** @type {Sid} smallId */ +var sid = s => s + "!"; diff --git a/tests/cases/fourslash/server/jsdocCallbackTag.ts b/tests/cases/fourslash/server/jsdocCallbackTag.ts new file mode 100644 index 00000000000..d0d944cc277 --- /dev/null +++ b/tests/cases/fourslash/server/jsdocCallbackTag.ts @@ -0,0 +1,31 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: jsdocCallbackTag.js + +//// /** +//// * @callback FooHandler +//// * @param {string} eventName - So many words +//// * @param eventName2 {number | string} - Silence is golden +//// * @param eventName3 - Osterreich mos def +//// */ +//// /** +//// * @type {FooHandler} callback +//// */ +//// var t/*1*/; +//// +//// /** +//// * @callback FooHandler2 - What, another one? +//// * @param {string=} eventName - it keeps happening +//// * @param {string} [eventName2] - i WARNED you dog +//// */ +//// /** +//// * @type {FooHandler2} callback +//// */ +//// var t2/*2*/; + + +goTo.marker("1"); +verify.quickInfoIs("var t: (eventName: string, eventName2: number | string, eventName3: any) => void"); +goTo.marker("2"); +verify.quickInfoIs("var t2: (eventName?: string, eventName2?: string) => void"); diff --git a/tests/cases/fourslash/server/jsdocCallbackTagNavigateTo.ts b/tests/cases/fourslash/server/jsdocCallbackTagNavigateTo.ts new file mode 100644 index 00000000000..e17192e65b7 --- /dev/null +++ b/tests/cases/fourslash/server/jsdocCallbackTagNavigateTo.ts @@ -0,0 +1,33 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: jsDocCallback.js + +//// /** +//// * @callback FooCallback +//// * @param {string} eventName - What even is the navigation bar? +//// */ +//// /** @type {FooCallback} */ +//// var t; + +verify.navigationBar([ + { + "text": "", + "kind": "module", + "childItems": [ + { + "text": "FooCallback", + "kind": "type" + }, + { + "text": "t", + "kind": "var" + } + ] + }, + { + "text": "FooCallback", + "kind": "type", + "indent": 1 + } +]) diff --git a/tests/cases/fourslash/server/jsdocCallbackTagRename01.ts b/tests/cases/fourslash/server/jsdocCallbackTagRename01.ts new file mode 100644 index 00000000000..bb7dd32cfc2 --- /dev/null +++ b/tests/cases/fourslash/server/jsdocCallbackTagRename01.ts @@ -0,0 +1,15 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: jsDocCallback.js +//// +//// /** +//// * @callback [|FooCallback|] +//// * @param {string} eventName - Rename should work +//// */ +//// +//// /** @type {/*1*/[|FooCallback|]} */ +//// var t; + +const ranges = test.ranges(); +verify.renameLocations(ranges[0], { findInStrings: false, findInComments: true, ranges });