question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Broken nestled jsdoc comments for overloaded functions

See original GitHub issue

Prettier 1.19.1 Playground link

--parser babel

Input:

const foo = "Bar";

/**
 * @template T
 * @param {Type} type
 * @param {T} value
 * @return {Value}
 *//**
 * @param {Type} type
 * @return {Value}
 */
function value(type, value) {
  if (arguments.length === 2) {
    return new ConcreteValue(type, value);
  } else {
    return new Value(type);
  }
}

Output:

const foo = "Bar";
/**
 * @param {Type} type
 * @return {Value}
 */

/**
 * @template T
 * @param {Type} type
 * @param {T} value
 * @return {Value}
 */ function value(type, value) {
  if (arguments.length === 2) {
    return new ConcreteValue(type, value);
  } else {
    return new Value(type);
  }
}

Expected behavior: Output identical to input.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
thw0rtedcommented, Jun 1, 2020

TS does not support it but tsd-jsdoc does, so this is breaking a live process today. JSDoc does parse it correctly as demonstrated in their issue, linked above.

0reactions
thorn0commented, Mar 6, 2020

Yes, TS doesn’t support this syntax. Related: https://github.com/microsoft/TypeScript/issues/25590

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documenting overloaded methods - Google Groups
Hello, I've been following JSDoc for nearly a couple of years now, and there's much to like! I still don't find the pipe|separation|of|method|params...
Read more >
3 Ways To Write Function Overloads With JSDoc & TypeScript
This article will show you how use JSDoc to provide TypeScript type definitions for overloaded functions in JavaScript.
Read more >
Document overloaded function in JSDoc - Stack Overflow
Save this question. Show activity on this post. I have an overloaded toggle function and want to document the behaviors w/ JSDoc.
Read more >
PhpStorm - Code Inspections in JavaScript and TypeScript
Reports mismatch between the names and the number of parameters within a JSDoc comment and the actual parameters of a function. Suggests ...
Read more >
angular-tslint-rules: a configuration preset for both ... - Medium
Do not invoke the super method twice in a constructor (except in branched statements or nested ... JSDoc comments should start with /**...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found