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.

please alias jsdoc doc comments to variable assignments

See original GitHub issue

Suggestion

🔍 Search Terms

typescript alias jsdoc to variable assignment

✅ Viability Checklist

My suggestion meets these guidelines:

  • This wouldn’t be a breaking change in existing TypeScript/JavaScript code
  • This wouldn’t change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn’t a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
  • This feature would agree with the rest of TypeScript’s Design Goals.

⭐ Suggestion

Please copy JSDoc data to aliased variables.

📃 Motivating Example

/** Call this in order to something. */
const foo = (s: string): number => 123

const f = foo

f // hovering on 'f' does not show the documentation description "Call this in order to something."

playground

💻 Use Cases

Make documentation easier. All projects need good documentation!

Workaround:

an author can copy/paste duplicate JSDoc comments. This is harder to maintain.

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:10
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
verikonocommented, Nov 11, 2022

Big props to this… If i get another sermon about semantic reasoning from my boss I think I shall surely die… He’s all about those multilevel type aliasing, type branding and guarding and now he’s worked out that with async/await everywhere… those type guards are getting very very very composed… unlike myself.

1reaction
remcohaszingcommented, Aug 26, 2022

Could this also be applied to type aliases too?

/**
 * This is a type
 */
type Foo = string | number

type Bar = Foo

// hovering on 'Bar' does not show the documentation description "This is atype"
export { Bar }

This is especially useful for types in jsdoc

/**
 * @typedef {import('vscode-languageserver-types').Range} Range
 */

// jsdoc information is lost for 'Range'
/**
 * @param {Range} range
 */
function handleRange(range) {}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Use JSDoc: @alias
The @alias tag causes JSDoc to treat all references to a member as if the member had a different name. This tag is...
Read more >
eslint-plugin-jsdoc - npm
Start using eslint-plugin-jsdoc in your project by running `npm i ... be checked to find a jsdoc comment block before the given code...
Read more >
How to document a Require.js (AMD) Modul with jsdoc 3 or ...
This is my first answer on SO, please let me know how I can improve future answers. Your specific example. I've been searching...
Read more >
JSDoc typings: all the benefits of TypeScript, with none of the ...
Is this code regular JavaScript? Yes. We just added some comments. Those comments are JSDocs typing comments. Let's look at the JSDoc: It...
Read more >
JSDoc Reference - TypeScript: Documentation
Declared in a TypeScript declaration, either global or imported. Declared in a JSDoc @typedef tag. You can use most JSDoc type syntax and...
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