forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable parsing of nested parameters for
@callback
JSDoc tag. (micro…
…soft#54681) Co-authored-by: Matej Sadovsky <[email protected]> Co-authored-by: Nathan Shively-Sanders <[email protected]>
- Loading branch information
1 parent
ed5008d
commit 34f6e10
Showing
5 changed files
with
116 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
//// [tests/cases/conformance/jsdoc/callbackTagNestedParameter.ts] //// | ||
|
||
//// [cb_nested.js] | ||
/** | ||
* @callback WorksWithPeopleCallback | ||
* @param {Object} person | ||
* @param {string} person.name | ||
* @param {number} [person.age] | ||
* @returns {void} | ||
*/ | ||
|
||
/** | ||
* For each person, calls your callback. | ||
* @param {WorksWithPeopleCallback} callback | ||
* @returns {void} | ||
*/ | ||
function eachPerson(callback) { | ||
callback({ name: "Empty" }); | ||
} | ||
|
||
|
||
|
||
|
||
//// [cb_nested.d.ts] | ||
/** | ||
* @callback WorksWithPeopleCallback | ||
* @param {Object} person | ||
* @param {string} person.name | ||
* @param {number} [person.age] | ||
* @returns {void} | ||
*/ | ||
/** | ||
* For each person, calls your callback. | ||
* @param {WorksWithPeopleCallback} callback | ||
* @returns {void} | ||
*/ | ||
declare function eachPerson(callback: WorksWithPeopleCallback): void; | ||
type WorksWithPeopleCallback = (person: { | ||
name: string; | ||
age?: number; | ||
}) => void; |
25 changes: 25 additions & 0 deletions
25
tests/baselines/reference/callbackTagNestedParameter.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//// [tests/cases/conformance/jsdoc/callbackTagNestedParameter.ts] //// | ||
|
||
=== cb_nested.js === | ||
/** | ||
* @callback WorksWithPeopleCallback | ||
* @param {Object} person | ||
* @param {string} person.name | ||
* @param {number} [person.age] | ||
* @returns {void} | ||
*/ | ||
|
||
/** | ||
* For each person, calls your callback. | ||
* @param {WorksWithPeopleCallback} callback | ||
* @returns {void} | ||
*/ | ||
function eachPerson(callback) { | ||
>eachPerson : Symbol(eachPerson, Decl(cb_nested.js, 0, 0)) | ||
>callback : Symbol(callback, Decl(cb_nested.js, 13, 20)) | ||
|
||
callback({ name: "Empty" }); | ||
>callback : Symbol(callback, Decl(cb_nested.js, 13, 20)) | ||
>name : Symbol(name, Decl(cb_nested.js, 14, 14)) | ||
} | ||
|
28 changes: 28 additions & 0 deletions
28
tests/baselines/reference/callbackTagNestedParameter.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
//// [tests/cases/conformance/jsdoc/callbackTagNestedParameter.ts] //// | ||
|
||
=== cb_nested.js === | ||
/** | ||
* @callback WorksWithPeopleCallback | ||
* @param {Object} person | ||
* @param {string} person.name | ||
* @param {number} [person.age] | ||
* @returns {void} | ||
*/ | ||
|
||
/** | ||
* For each person, calls your callback. | ||
* @param {WorksWithPeopleCallback} callback | ||
* @returns {void} | ||
*/ | ||
function eachPerson(callback) { | ||
>eachPerson : (callback: WorksWithPeopleCallback) => void | ||
>callback : WorksWithPeopleCallback | ||
|
||
callback({ name: "Empty" }); | ||
>callback({ name: "Empty" }) : void | ||
>callback : WorksWithPeopleCallback | ||
>{ name: "Empty" } : { name: string; } | ||
>name : string | ||
>"Empty" : "Empty" | ||
} | ||
|
21 changes: 21 additions & 0 deletions
21
tests/cases/conformance/jsdoc/callbackTagNestedParameter.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// @emitDeclarationOnly: true | ||
// @declaration: true | ||
// @allowJs: true | ||
// @checkJs: true | ||
// @Filename: cb_nested.js | ||
/** | ||
* @callback WorksWithPeopleCallback | ||
* @param {Object} person | ||
* @param {string} person.name | ||
* @param {number} [person.age] | ||
* @returns {void} | ||
*/ | ||
|
||
/** | ||
* For each person, calls your callback. | ||
* @param {WorksWithPeopleCallback} callback | ||
* @returns {void} | ||
*/ | ||
function eachPerson(callback) { | ||
callback({ name: "Empty" }); | ||
} |