diff --git a/internal/parser/reparser.go b/internal/parser/reparser.go index d482e8ad72..cbb48352ab 100644 --- a/internal/parser/reparser.go +++ b/internal/parser/reparser.go @@ -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 diff --git a/testdata/baselines/reference/compiler/jsdocCallbackParamQualifiedName.errors.txt b/testdata/baselines/reference/compiler/jsdocCallbackParamQualifiedName.errors.txt new file mode 100644 index 0000000000..487c98d509 --- /dev/null +++ b/testdata/baselines/reference/compiler/jsdocCallbackParamQualifiedName.errors.txt @@ -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'. + } + \ No newline at end of file diff --git a/testdata/baselines/reference/compiler/jsdocCallbackParamQualifiedName.symbols b/testdata/baselines/reference/compiler/jsdocCallbackParamQualifiedName.symbols new file mode 100644 index 0000000000..af3105570c --- /dev/null +++ b/testdata/baselines/reference/compiler/jsdocCallbackParamQualifiedName.symbols @@ -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)) +} + diff --git a/testdata/baselines/reference/compiler/jsdocCallbackParamQualifiedName.types b/testdata/baselines/reference/compiler/jsdocCallbackParamQualifiedName.types new file mode 100644 index 0000000000..5c2595bf02 --- /dev/null +++ b/testdata/baselines/reference/compiler/jsdocCallbackParamQualifiedName.types @@ -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 +} + diff --git a/testdata/tests/cases/compiler/jsdocCallbackParamQualifiedName.ts b/testdata/tests/cases/compiler/jsdocCallbackParamQualifiedName.ts new file mode 100644 index 0000000000..98f5575ffc --- /dev/null +++ b/testdata/tests/cases/compiler/jsdocCallbackParamQualifiedName.ts @@ -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 + */ + +/** + * @overload + * @param {object} x + * @param {string} x.y + * @returns {string} + */ +/** + * @param {object} x + * @returns {string} + */ +function foo(x) { + return x.y; +}