@@ -43,7 +43,7 @@ func (p *Parser) reparseTags(parent *ast.Node, jsDoc []*ast.Node) {
4343 if tags == nil {
4444 continue
4545 }
46- for _ , tag := range j . AsJSDoc (). Tags .Nodes {
46+ for _ , tag := range tags .Nodes {
4747 switch tag .Kind {
4848 case ast .KindJSDocTypedefTag :
4949 // !!! Don't mark typedefs as exported if they are not in a module
@@ -67,7 +67,14 @@ func (p *Parser) reparseTags(parent *ast.Node, jsDoc []*ast.Node) {
6767 case ast .KindJSDocTypeLiteral :
6868 members := p .nodeSlicePool .NewSlice (0 )
6969 for _ , member := range typeExpression .AsJSDocTypeLiteral ().JSDocPropertyTags {
70- prop := p .factory .NewPropertySignatureDeclaration (nil , member .Name (), nil /*postfixToken*/ , member .Type (), nil /*initializer*/ )
70+ var questionToken * ast.TokenNode
71+ if member .AsJSDocPropertyTag ().IsBracketed ||
72+ member .AsJSDocPropertyTag ().TypeExpression != nil && member .AsJSDocPropertyTag ().TypeExpression .Type ().Kind == ast .KindJSDocOptionalType {
73+ questionToken = p .factory .NewToken (ast .KindQuestionToken )
74+ questionToken .Loc = core .NewTextRange (member .Pos (), member .End ())
75+ questionToken .Flags = p .contextFlags | ast .NodeFlagsReparsed
76+ }
77+ prop := p .factory .NewPropertySignatureDeclaration (nil , member .Name (), questionToken , member .Type (), nil /*initializer*/ )
7178 prop .Loc = member .Loc
7279 prop .Flags = p .contextFlags | ast .NodeFlagsReparsed
7380 members = append (members , prop )
0 commit comments