jsdoc / jsdoc/jsdoc

Inline syntax

Open
#2,098 9 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
15.5k
Forks
1.5k
Avg merge
10d 23h
Merged PRs (30d)
1

Description

As suggested at https://github.com/tc39/proposal-type-annotations/issues/202#issuecomment-1833797860, I have a proposal for a minimal inline syntax for types. The idea is to consider any comment where the first token is a JsDoc token (without the @) as a JsDoc comment, and also being in that case the : an alias to @type, so it's possible to have an inline syntax with a readibility similar to Typescript or flow. That would make JsDoc expresiveness more alike to https://tsdoc.org/, where there's no need to be so much verbose because most of the information is get from Typescript keywords (in that case, the inline comments):

const num /*:number*/ = 42;

/**
 * @param a The first argument
 * @param b The second argument
 *
 * @return The sum of both arguments
 */
function func(a/*:number*/, b/*:number*/)/*:number*/
{
  return a + b
}

/*
type A
{
  name: string
}
*/

class B /*implements A*/{}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the linked TC39 proposal discussion and the inline examples in this issue, then trace how JSDoc currently recognizes comments and type annotations. Compare the proposed forms for variables, parameters, return values, and classes, and define completion as documented, tested support for the agreed syntax.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
documentation
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.