Skip to content
Open
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
5 changes: 5 additions & 0 deletions internal/parser/reparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ func (p *Parser) reparseJSDocSignature(jsSignature *ast.Node, fun *ast.Node, jsD
}
} else if param.Kind == ast.KindJSDocParameterTag || param.Kind == ast.KindJSDocPropertyTag {
jsparam := param.AsJSDocParameterOrPropertyTag()
// Skip sub-property parameters (e.g., @param x.y) - these have QualifiedNames
// and describe properties of a parent parameter, not standalone parameters.
if ast.IsQualifiedName(jsparam.Name()) {
continue
}
var dotDotDotToken *ast.Node
var paramType *ast.TypeNode

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
bug.js(23,14): error TS2339: Property 'y' does not exist on type 'object'.


==== bug.js (1 errors) ====
/**
* @callback cb
* @param x.y
*/

/**
* @callback cb2
* @param {object} x
* @param {string} x.y
*/

/**
* @overload
* @param {object} x
* @param {string} x.y
* @returns {string}
*/
/**
* @param {object} x
* @returns {string}
*/
function foo(x) {
return x.y;
~
!!! error TS2339: Property 'y' does not exist on type 'object'.
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//// [tests/cases/compiler/jsdocCallbackParamQualifiedName.ts] ////

=== bug.js ===
/**
* @callback cb
* @param x.y
*/

/**
* @callback cb2
* @param {object} x
* @param {string} x.y
*/

/**
* @overload
* @param {object} x
* @param {string} x.y
* @returns {string}
*/
/**
* @param {object} x
* @returns {string}
*/
function foo(x) {
>foo : Symbol(foo, Decl(bug.js, 12, 4), Decl(bug.js, 0, 0))
>x : Symbol(x, Decl(bug.js, 21, 13))

return x.y;
>x : Symbol(x, Decl(bug.js, 21, 13))
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//// [tests/cases/compiler/jsdocCallbackParamQualifiedName.ts] ////

=== bug.js ===
/**
* @callback cb
* @param x.y
*/

/**
* @callback cb2
* @param {object} x
* @param {string} x.y
*/

/**
* @overload
* @param {object} x
* @param {string} x.y
* @returns {string}
*/
/**
* @param {object} x
* @returns {string}
*/
function foo(x) {
>foo : (x: { y: string; }) => string
>x : object

return x.y;
>x.y : any
>x : object
>y : any
}

29 changes: 29 additions & 0 deletions testdata/tests/cases/compiler/jsdocCallbackParamQualifiedName.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// @allowJs: true
// @checkJs: true
// @noEmit: true

// @filename: bug.js
/**
* @callback cb
* @param x.y
*/

/**
* @callback cb2
* @param {object} x
* @param {string} x.y
*/
Comment on lines +6 to +15
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added an @overload test case with a qualified @param x.y in dac3328.


/**
* @overload
* @param {object} x
* @param {string} x.y
* @returns {string}
*/
/**
* @param {object} x
* @returns {string}
*/
function foo(x) {
return x.y;
}