File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13318,8 +13318,13 @@ namespace ts {
1331813318 for (const child of (parent as JsxElement).children) {
1331913319 // In React, JSX text that contains only whitespaces will be ignored so we don't want to type-check that
1332013320 // because then type of children property will have constituent of string type.
13321- if (child.kind !== SyntaxKind.JsxTextAllWhiteSpaces) {
13322- childrenTypes.push(child.kind === SyntaxKind.JsxText ? stringType : checkExpression(child as Expression, checkMode));
13321+ if (child.kind === SyntaxKind.JsxText) {
13322+ if (!child.containsOnlyWhiteSpaces) {
13323+ childrenTypes.push(stringType);
13324+ }
13325+ }
13326+ else {
13327+ childrenTypes.push(checkExpression(child, checkMode));
1332313328 }
1332413329 }
1332513330 childrenPropSymbol.type = getUnionType(childrenTypes, /*subtypeReduction*/ false);
Original file line number Diff line number Diff line change @@ -3825,7 +3825,8 @@ namespace ts {
38253825 }
38263826
38273827 function parseJsxText ( ) : JsxText {
3828- const node = < JsxText > createNode ( currentToken , scanner . getStartPos ( ) ) ;
3828+ const node = < JsxText > createNode ( SyntaxKind . JsxText , scanner . getStartPos ( ) ) ;
3829+ node . containsOnlyWhiteSpaces = currentToken === SyntaxKind . JsxTextAllWhiteSpaces ;
38293830 currentToken = scanner . scanJsxToken ( ) ;
38303831 return finishNode ( node ) ;
38313832 }
Original file line number Diff line number Diff line change @@ -1729,7 +1729,6 @@ namespace ts {
17291729 // firstNonWhitespace = 0 to indicate that we want leading whitspace,
17301730
17311731 while ( pos < end ) {
1732- pos ++ ;
17331732 char = text . charCodeAt ( pos ) ;
17341733 if ( char === CharacterCodes . openBrace ) {
17351734 break ;
@@ -1754,6 +1753,7 @@ namespace ts {
17541753 else if ( ! isWhiteSpaceSingleLine ( char ) ) {
17551754 firstNonWhitespace = pos ;
17561755 }
1756+ pos ++ ;
17571757 }
17581758
17591759 return firstNonWhitespace === - 1 ? SyntaxKind . JsxTextAllWhiteSpaces : SyntaxKind . JsxText ;
Original file line number Diff line number Diff line change 15721572 }
15731573
15741574 export interface JsxText extends Node {
1575- kind : SyntaxKind . JsxText ;
1575+ kind : SyntaxKind . JsxText ,
1576+ containsOnlyWhiteSpaces : boolean ,
15761577 parent ?: JsxElement ;
15771578 }
15781579
You can’t perform that action at this time.
0 commit comments