File tree Expand file tree Collapse file tree 2 files changed +12
-9
lines changed Expand file tree Collapse file tree 2 files changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -6135,10 +6135,14 @@ namespace ts {
6135
6135
}
6136
6136
6137
6137
// Parses out a JSDoc type expression.
6138
- export function parseJSDocTypeExpression ( ) : JSDocTypeExpression {
6138
+ export function parseJSDocTypeExpression ( ) : JSDocTypeExpression ;
6139
+ export function parseJSDocTypeExpression ( requireBraces : true ) : JSDocTypeExpression | undefined ;
6140
+ export function parseJSDocTypeExpression ( requireBraces ?: boolean ) : JSDocTypeExpression | undefined {
6139
6141
const result = < JSDocTypeExpression > createNode ( SyntaxKind . JSDocTypeExpression , scanner . getTokenPos ( ) ) ;
6140
6142
6141
- parseExpected ( SyntaxKind . OpenBraceToken ) ;
6143
+ if ( ! parseExpected ( SyntaxKind . OpenBraceToken ) && requireBraces ) {
6144
+ return undefined ;
6145
+ }
6142
6146
result . type = doInsideOfContext ( NodeFlags . JSDoc , parseType ) ;
6143
6147
parseExpected ( SyntaxKind . CloseBraceToken ) ;
6144
6148
@@ -6595,7 +6599,7 @@ namespace ts {
6595
6599
const result = < JSDocTypeTag > createNode ( SyntaxKind . JSDocTypeTag , atToken . pos ) ;
6596
6600
result . atToken = atToken ;
6597
6601
result . tagName = tagName ;
6598
- result . typeExpression = tryParseTypeExpression ( ) ;
6602
+ result . typeExpression = parseJSDocTypeExpression ( /*mayBail*/ true ) ;
6599
6603
return finishNode ( result ) ;
6600
6604
}
6601
6605
Original file line number Diff line number Diff line change @@ -139,6 +139,11 @@ namespace ts {
139
139
`/**
140
140
* @param
141
141
*/` ) ;
142
+
143
+ parsesIncorrectly ( "noType" ,
144
+ `/**
145
+ * @type
146
+ */` ) ;
142
147
} ) ;
143
148
144
149
describe ( "parsesCorrectly" , ( ) => {
@@ -148,12 +153,6 @@ namespace ts {
148
153
*/` ) ;
149
154
150
155
151
- parsesCorrectly ( "noType" ,
152
- `/**
153
- * @type
154
- */` ) ;
155
-
156
-
157
156
parsesCorrectly ( "noReturnType" ,
158
157
`/**
159
158
* @return
You can’t perform that action at this time.
0 commit comments