Skip to content

Declaration-like jsdocs are incorrectly attached to the following statementΒ #43534

@thorn0

Description

@thorn0

Bug Report

πŸ”Ž Search Terms

jsdoc docblock typedef

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried

⏯ Playground Link

playground

πŸ’» Code

/** @typedef {{foo: 'foo'}} Foo */

function f() {
}

f()

πŸ™ Actual behavior

Whenever JSDoc typedef blocks are followed by a function (or variable) declaration TS attaches that JSDoc to the function and shows typedefs as part of the function's description when its name is hovered.

image

(The described behavior is old, but the screenshot of v4.3.0-dev is here to show an extra bug with [object Object].)

πŸ™‚ Expected behavior

Typedefs shouldn't be attached to subsequent statements.

As @sandersn wrote in #42895 (comment):

Declaration-like jsdocs are incorrectly attached to the following statement. The fix is probably as simple as a filter somewhere -- the compiler itself doesn't care where @typedef is, only the services layer does -- but I'm not sure which component should do the filtering.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptDomain: JSDocRelates to JSDoc parsing and type generationFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions