Repository navigation
Description
TypeScript Version: 2.5.3
Code
/**
* @const {boolean} This constant is falsy
*/
export const MyFalsyConstant: boolean = false;Expected behavior:
Type expression and comment should be separate for @const (http://usejsdoc.org/tags-constant.html) tags. See below for further explanation.
Actual behavior:
Parsing the above JSDoc (with help from tsutils which as far as I can see is just using Typescript parsing tools), I get the following node for the @const JSDoc tag.
NodeObject {
pos: 1299,
end: 1306,
flags: 0,
transformFlags: undefined,
parent:
NodeObject {
pos: 1292,
end: 1368,
flags: 0,
transformFlags: undefined,
parent:
NodeObject {
pos: 1290,
end: 1406,
flags: 0,
transformFlags: undefined,
parent: [Object],
kind: 208,
decorators: undefined,
modifiers: undefined,
declarationList: [Object],
jsDoc: [Object],
_children: [Object] },
kind: 275,
tags: [ [Circular], [Object], pos: 1299, end: 1348 ],
comment: undefined },
kind: 276,
atToken: TokenObject { pos: 1299, end: 1300, flags: 0, parent: undefined, kind: 57 },
tagName:
IdentifierObject {
pos: 1300,
end: 1305,
flags: 0,
parent: undefined,
escapedText: 'const' },
comment: '{false} This constant is falsy' }
Destructuring the relevant ts.JSDocTag object (const { typeExpression, comment } = tag), I get the following:
typeExpression: `undefined`
comment: `{false} This constant is falsy`
My expectation would be for the type expression to be separate as outlined in http://usejsdoc.org/tags-constant.html
Activity
[-]`@const` JSDoc tag doesn't separate `typeExpression` from `comment`[/-][+]Support `@const` JSDoc tag [/+]mhegazy commentedon Nov 1, 2017
PRs welcomed.
j-oliveras commentedon Mar 28, 2018
Mohamed Hegazy (@mhegazy) Maybe you want to add
help wantedlabel to this issue (based on your previous comment).Kingwl commentedon Jul 27, 2020
I’d like to work on this.
zachhardesty7 commentedon Feb 2, 2021
has any progress been made on this issue? from what I can tell, it looks like #39768 was finished but closed.
frank-dspeed commentedon Apr 14, 2022
This can be closed Typescript now Supports: since version 4.5+ #39768 implements it
is type
works like a charm Ryan Cavanaugh (@RyanCavanaugh)
https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html#unsupported-tags <- needs a update i do not remember where the issues are for this.
bjarkler commentedon Apr 26, 2022
I don't think this is fixed - can we reopen, Ryan Cavanaugh (@RyanCavanaugh)? #39768 was closed without being merged, and the example in the previous comment uses the
@typetag, not the@consttag which this issue is referring to.frank-dspeed commentedon Apr 26, 2022
bjarkler i guess there is no real implementation ongoing with the Constantine Plotnikov (@const) JSDoc tag what now works is the so called typecasting to const so the same as in typescript with
as consti guess thats because it needs to get done and made sure that it is only on assignment.
GreenAsJade commentedon Jul 14, 2022
Note that the documentation for Typescript points to this issue as being open on this tag.