Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/compiler/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9150,7 +9150,7 @@ namespace Parser {

const comment = parseTrailingTagComments(start, getNodePos(), indent, indentText);

const nestedTypeLiteral = target !== PropertyLikeParse.CallbackParameter && parseNestedTypeLiteral(typeExpression, name, target, indent);
const nestedTypeLiteral = parseNestedTypeLiteral(typeExpression, name, target, indent);
if (nestedTypeLiteral) {
typeExpression = nestedTypeLiteral;
isNameFirst = true;
Expand Down Expand Up @@ -9465,7 +9465,6 @@ namespace Parser {
if (canParseTag) {
const child = tryParseChildTag(target, indent);
if (child && (child.kind === SyntaxKind.JSDocParameterTag || child.kind === SyntaxKind.JSDocPropertyTag) &&
target !== PropertyLikeParse.CallbackParameter &&
name && (isIdentifierNode(child.name) || !escapedTextsEqual(name, child.name.left))) {
return false;
}
Expand Down
41 changes: 41 additions & 0 deletions tests/baselines/reference/callbackTagNestedParameter.js
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 tests/baselines/reference/callbackTagNestedParameter.symbols
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 tests/baselines/reference/callbackTagNestedParameter.types
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 tests/cases/conformance/jsdoc/callbackTagNestedParameter.ts
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" });
}