File tree 1 file changed +15
-5
lines changed
1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -3131,12 +3131,22 @@ module ts {
3131
3131
// if it's a self closing tag it's a JSXElement and not a type assertion
3132
3132
speculative = false ;
3133
3133
}
3134
- else if ( speculative && ! hasClosingTagAfterPos ( tagName , scanner . getStartPos ( ) ) ) {
3135
- // we are in speculative parsing and we were not able to find a corresponding closing tag
3136
- // farther in the source text
3137
- return null ;
3138
- }
3139
3134
else {
3135
+ if ( speculative && ! hasClosingTagAfterPos ( tagName , scanner . getStartPos ( ) ) ) {
3136
+ // we are in speculative parsing and we were not able to find a corresponding closing tag
3137
+ // farther in the source text, we try to determine if the following tokens look like normal
3138
+ // part of jsx children to decide if we continue parsing the JSXElement children
3139
+ let shouldContinueJSXParsing = lookAhead ( ( ) => {
3140
+ const t = token ;
3141
+ const next = nextToken ( ) ;
3142
+ return t === SyntaxKind . LessThanToken || // <foo><...
3143
+ ( t >= SyntaxKind . Identifier && next === SyntaxKind . OpenBraceToken ) || // '<foo> bar {...
3144
+ ( t >= SyntaxKind . Identifier && next >= SyntaxKind . Identifier ) // '<foo> foo bar ...
3145
+ } ) ;
3146
+ if ( ! shouldContinueJSXParsing ) {
3147
+ return null ;
3148
+ }
3149
+ }
3140
3150
//we can't use parseList we need to intercept ' }‘ token in speculative mode
3141
3151
let savedStrictModeContext = inStrictModeContext ( ) ;
3142
3152
You can’t perform that action at this time.
0 commit comments