@@ -3,7 +3,7 @@ namespace ts {
33 None = 0 ,
44 Yield = 1 << 0 ,
55 Await = 1 << 1 ,
6- Type = 1 << 2 ,
6+ Type = 1 << 2 ,
77 IgnoreMissingOpenBrace = 1 << 4 ,
88 JSDoc = 1 << 5 ,
99 }
@@ -474,9 +474,9 @@ namespace ts {
474474 return visitNode ( cbNode , ( node as JSDocTag ) . tagName ) ||
475475 ( ( node as JSDocPropertyLikeTag ) . isNameFirst
476476 ? visitNode ( cbNode , ( < JSDocPropertyLikeTag > node ) . name ) ||
477- visitNode ( cbNode , ( < JSDocPropertyLikeTag > node ) . typeExpression )
477+ visitNode ( cbNode , ( < JSDocPropertyLikeTag > node ) . typeExpression )
478478 : visitNode ( cbNode , ( < JSDocPropertyLikeTag > node ) . typeExpression ) ||
479- visitNode ( cbNode , ( < JSDocPropertyLikeTag > node ) . name ) ) ;
479+ visitNode ( cbNode , ( < JSDocPropertyLikeTag > node ) . name ) ) ;
480480 case SyntaxKind . JSDocAuthorTag :
481481 return visitNode ( cbNode , ( node as JSDocTag ) . tagName ) ;
482482 case SyntaxKind . JSDocImplementsTag :
@@ -494,9 +494,9 @@ namespace ts {
494494 ( ( node as JSDocTypedefTag ) . typeExpression &&
495495 ( node as JSDocTypedefTag ) . typeExpression ! . kind === SyntaxKind . JSDocTypeExpression
496496 ? visitNode ( cbNode , ( < JSDocTypedefTag > node ) . typeExpression ) ||
497- visitNode ( cbNode , ( < JSDocTypedefTag > node ) . fullName )
497+ visitNode ( cbNode , ( < JSDocTypedefTag > node ) . fullName )
498498 : visitNode ( cbNode , ( < JSDocTypedefTag > node ) . fullName ) ||
499- visitNode ( cbNode , ( < JSDocTypedefTag > node ) . typeExpression ) ) ;
499+ visitNode ( cbNode , ( < JSDocTypedefTag > node ) . typeExpression ) ) ;
500500 case SyntaxKind . JSDocCallbackTag :
501501 return visitNode ( cbNode , ( node as JSDocTag ) . tagName ) ||
502502 visitNode ( cbNode , ( node as JSDocCallbackTag ) . fullName ) ||
@@ -846,7 +846,7 @@ namespace ts {
846846 statement . expression = parseLiteralNode ( ) as StringLiteral | NumericLiteral ;
847847 break ;
848848 }
849- // falls through
849+ // falls through
850850 default :
851851 statement . expression = parseObjectLiteralExpression ( ) ;
852852 break ;
@@ -1394,8 +1394,8 @@ namespace ts {
13941394 const p = pos ! >= 0 ? pos ! : scanner . getStartPos ( ) ;
13951395 return isNodeKind ( kind ) || kind === SyntaxKind . Unknown ? new NodeConstructor ( kind , p , p ) :
13961396 kind === SyntaxKind . Identifier ? new IdentifierConstructor ( kind , p , p ) :
1397- kind === SyntaxKind . PrivateIdentifier ? new PrivateIdentifierConstructor ( kind , p , p ) :
1398- new TokenConstructor ( kind , p , p ) ;
1397+ kind === SyntaxKind . PrivateIdentifier ? new PrivateIdentifierConstructor ( kind , p , p ) :
1398+ new TokenConstructor ( kind , p , p ) ;
13991399 }
14001400
14011401 function createNodeWithJSDoc ( kind : SyntaxKind , pos ?: number ) : Node {
@@ -1708,7 +1708,7 @@ namespace ts {
17081708 case SyntaxKind . DotToken : // Not an array literal member, but don't want to close the array (see `tests/cases/fourslash/completionsDotInArrayLiteralInObjectLiteral.ts`)
17091709 return true ;
17101710 }
1711- // falls through
1711+ // falls through
17121712 case ParsingContext . ArgumentExpressions :
17131713 return token ( ) === SyntaxKind . DotDotDotToken || isStartOfExpression ( ) ;
17141714 case ParsingContext . Parameters :
@@ -3153,7 +3153,7 @@ namespace ts {
31533153 case SyntaxKind . QuestionQuestionToken :
31543154 // If there is '??', consider that is prefix '?' in JSDoc type.
31553155 scanner . reScanQuestionToken ( ) ;
3156- // falls through
3156+ // falls through
31573157 case SyntaxKind . QuestionToken :
31583158 return parseJSDocUnknownOrNullableType ( ) ;
31593159 case SyntaxKind . FunctionKeyword :
@@ -4250,7 +4250,7 @@ namespace ts {
42504250 if ( isAwaitExpression ( ) ) {
42514251 return parseAwaitExpression ( ) ;
42524252 }
4253- // falls through
4253+ // falls through
42544254 default :
42554255 return parseUpdateExpression ( ) ;
42564256 }
@@ -4284,8 +4284,8 @@ namespace ts {
42844284 if ( sourceFile . languageVariant !== LanguageVariant . JSX ) {
42854285 return false ;
42864286 }
4287- // We are in JSX context and the token is part of JSXElement.
4288- // falls through
4287+ // We are in JSX context and the token is part of JSXElement.
4288+ // falls through
42894289 default :
42904290 return true ;
42914291 }
@@ -4474,7 +4474,7 @@ namespace ts {
44744474 return finishNode ( node ) ;
44754475 }
44764476
4477- function parseJsxElementOrSelfClosingElementOrFragment ( inExpressionContext : boolean ) : JsxElement | JsxSelfClosingElement | JsxFragment {
4477+ function parseJsxElementOrSelfClosingElementOrFragment ( inExpressionContext : boolean , topInvalidNodePosition ?: number ) : JsxElement | JsxSelfClosingElement | JsxFragment {
44784478 const opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment ( inExpressionContext ) ;
44794479 let result : JsxElement | JsxSelfClosingElement | JsxFragment ;
44804480 if ( opening . kind === SyntaxKind . JsxOpeningElement ) {
@@ -4512,15 +4512,16 @@ namespace ts {
45124512 // Since JSX elements are invalid < operands anyway, this lookahead parse will only occur in error scenarios
45134513 // of one sort or another.
45144514 if ( inExpressionContext && token ( ) === SyntaxKind . LessThanToken ) {
4515- const invalidElement = tryParse ( ( ) => parseJsxElementOrSelfClosingElementOrFragment ( /*inExpressionContext*/ true ) ) ;
4515+ const topBadPos = typeof topInvalidNodePosition === "undefined" ? result . pos : topInvalidNodePosition ;
4516+ const invalidElement = tryParse ( ( ) => parseJsxElementOrSelfClosingElementOrFragment ( /*inExpressionContext*/ true , topBadPos ) ) ;
45164517 if ( invalidElement ) {
4517- parseErrorAtCurrentToken ( Diagnostics . JSX_expressions_must_have_one_parent_element ) ;
45184518 const badNode = < BinaryExpression > createNode ( SyntaxKind . BinaryExpression , result . pos ) ;
45194519 badNode . end = invalidElement . end ;
45204520 badNode . left = result ;
45214521 badNode . right = invalidElement ;
45224522 badNode . operatorToken = createMissingNode ( SyntaxKind . CommaToken , /*reportAtCurrentPosition*/ false ) ;
45234523 badNode . operatorToken . pos = badNode . operatorToken . end = badNode . right . pos ;
4524+ parseErrorAt ( topBadPos , invalidElement . end , Diagnostics . JSX_expressions_must_have_one_parent_element ) ;
45244525 return < JsxElement > < Node > badNode ;
45254526 }
45264527 }
@@ -5064,7 +5065,7 @@ namespace ts {
50645065 function parseArgumentOrArrayLiteralElement ( ) : Expression {
50655066 return token ( ) === SyntaxKind . DotDotDotToken ? parseSpreadElement ( ) :
50665067 token ( ) === SyntaxKind . CommaToken ? < Expression > createNode ( SyntaxKind . OmittedExpression ) :
5067- parseAssignmentExpressionOrHigher ( ) ;
5068+ parseAssignmentExpressionOrHigher ( ) ;
50685069 }
50695070
50705071 function parseArgumentExpression ( ) : Expression {
@@ -5175,9 +5176,9 @@ namespace ts {
51755176 const isAsync = hasModifierOfKind ( node , SyntaxKind . AsyncKeyword ) ? SignatureFlags . Await : SignatureFlags . None ;
51765177 node . name =
51775178 isGenerator && isAsync ? doInYieldAndAwaitContext ( parseOptionalIdentifier ) :
5178- isGenerator ? doInYieldContext ( parseOptionalIdentifier ) :
5179- isAsync ? doInAwaitContext ( parseOptionalIdentifier ) :
5180- parseOptionalIdentifier ( ) ;
5179+ isGenerator ? doInYieldContext ( parseOptionalIdentifier ) :
5180+ isAsync ? doInAwaitContext ( parseOptionalIdentifier ) :
5181+ parseOptionalIdentifier ( ) ;
51815182
51825183 fillSignature ( SyntaxKind . ColonToken , isGenerator | isAsync , node ) ;
51835184 node . body = parseFunctionBlock ( isGenerator | isAsync ) ;
@@ -6720,8 +6721,8 @@ namespace ts {
67206721 // Try to use the first top-level import/export when available, then
67216722 // fall back to looking for an 'import.meta' somewhere in the tree if necessary.
67226723 sourceFile . externalModuleIndicator =
6723- forEach ( sourceFile . statements , isAnExternalModuleIndicatorNode ) ||
6724- getImportMetaIfNecessary ( sourceFile ) ;
6724+ forEach ( sourceFile . statements , isAnExternalModuleIndicatorNode ) ||
6725+ getImportMetaIfNecessary ( sourceFile ) ;
67256726 }
67266727
67276728 function isAnExternalModuleIndicatorNode ( node : Node ) {
@@ -7141,7 +7142,7 @@ namespace ts {
71417142 break ;
71427143 }
71437144 scanner . setTextPos ( scanner . getTextPos ( ) - 1 ) ;
7144- // falls through
7145+ // falls through
71457146 case SyntaxKind . EndOfFileToken :
71467147 // Done
71477148 break loop;
@@ -7184,8 +7185,8 @@ namespace ts {
71847185 indent += 1 ;
71857186 break ;
71867187 }
7187- // record the * as a comment
7188- // falls through
7188+ // record the * as a comment
7189+ // falls through
71897190 default :
71907191 if ( state !== JSDocState . SavingBackticks ) {
71917192 state = JSDocState . SavingComments ; // leading identifiers start recording as well
@@ -8499,7 +8500,7 @@ namespace ts {
84998500 return ;
85008501 }
85018502 if ( pragma . args ) {
8502- const argument : { [ index : string ] : string | { value : string , pos : number , end : number } } = { } ;
8503+ const argument : { [ index : string ] : string | { value : string , pos : number , end : number } } = { } ;
85038504 for ( const arg of pragma . args ) {
85048505 const matcher = getNamedArgRegEx ( arg . name ) ;
85058506 const matchResult = matcher . exec ( text ) ;
@@ -8556,11 +8557,11 @@ namespace ts {
85568557 return ;
85578558 }
85588559
8559- function getNamedPragmaArguments ( pragma : PragmaDefinition , text : string | undefined ) : { [ index : string ] : string } | "fail" {
8560+ function getNamedPragmaArguments ( pragma : PragmaDefinition , text : string | undefined ) : { [ index : string ] : string } | "fail" {
85608561 if ( ! text ) return { } ;
85618562 if ( ! pragma . args ) return { } ;
85628563 const args = text . split ( / \s + / ) ;
8563- const argMap : { [ index : string ] : string } = { } ;
8564+ const argMap : { [ index : string ] : string } = { } ;
85648565 for ( let i = 0 ; i < pragma . args . length ; i ++ ) {
85658566 const argument = pragma . args [ i ] ;
85668567 if ( ! args [ i ] && ! argument . optional ) {
0 commit comments