Inline syntax
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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