microsoft / microsoft/TypeScript
`@typedef` doesn't give error for bad or missing typename
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
/** @typedef {number} 3 */
/** @typedef {number */
Expected behavior:
Errors on both.
- "'3' is not a valid type alias name.'
- Missing type alias name.
Actual behavior:
Errors on neither, and neither alias can be used.
If you have a declaration following the typedef, you will get the name of that declaration instead. In the second case that's OK, but in the first case the '3' should still be an error:
/** @typedef {number} 3 - this should still be an error */
var Type1;
/** @typedef {number} */
var Type2; // should be allowed
Note that the type name is required: even if you provide a following name to use, we'll treat any valid identifier in the comment text as the type name in preference to the following name:
/** @typedef {number} A type */
var Type3;
This defines a type A not Type3. That's why we should issue an error when, for example, the text is '3' instead of '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 tracing how JSDoc @typedef comments are parsed and how their names are selected when a following declaration exists. Add coverage for the invalid name '3', the missing name, and the valid 'A type' case, then verify that both malformed typedefs produce errors while the missing-name case with a following declaration remains allowed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100