microsoft / microsoft/TypeScript
JSDoc type aliases aren't parsed or bound at the end of blocks
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 117
Description
Bug Report
Followup to #54037 and #53624
This is not a regression, and fixing it would require
- the parser to check for jsdoc before each close brace
- the ast to store optional jsdoc on each close brace, and store the close brace on each block
- the binder to visit each close brace to check for jsdoc to bind
So I think it's too expensive for a feature that nobody has noticed missing until recently.
🔎 Search Terms
JSDoc type alias ignored
🕗 Version & Regression Information
- This is the behavior in every version I tried
💻 Code
// @filename: typedefAtEndOfBlock.js
// @checkJs: true
// @outdir: dist
// @declaration: true
function f() {
/* @type {A} */
var a = 2
/** @typedef {string} A */
}
{
/* @type {B} */
var b = 2
/** @typedef {string} B */
}
export class Class {
/* @type {C} */
c = 1
/** @typedef {string} C */
}
const Dlass = class {
/* @type {D} */
d = 1
/** @typedef {string} D */
}
🙁 Actual behavior
None of the typedefs are parsed or bound.
🙂 Expected behavior
The typedefs are parsed and bound.
(And none are visible outside their containers, which is not true for classes right now).
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 with the typedefAtEndOfBlock.js reproduction and trace how the parser, AST, and binder handle JSDoc before closing braces. Compare the behavior described in #54037 and #53624. Done means the typedefs are parsed and bound within their containers, with the documented class visibility behavior addressed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100