File tree Expand file tree Collapse file tree 4 files changed +12
-5
lines changed Expand file tree Collapse file tree 4 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -13318,8 +13318,13 @@ namespace ts {
13318
13318
for (const child of (parent as JsxElement).children) {
13319
13319
// In React, JSX text that contains only whitespaces will be ignored so we don't want to type-check that
13320
13320
// 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));
13323
13328
}
13324
13329
}
13325
13330
childrenPropSymbol.type = getUnionType(childrenTypes, /*subtypeReduction*/ false);
Original file line number Diff line number Diff line change @@ -3825,7 +3825,8 @@ namespace ts {
3825
3825
}
3826
3826
3827
3827
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 ;
3829
3830
currentToken = scanner . scanJsxToken ( ) ;
3830
3831
return finishNode ( node ) ;
3831
3832
}
Original file line number Diff line number Diff line change @@ -1729,7 +1729,6 @@ namespace ts {
1729
1729
// firstNonWhitespace = 0 to indicate that we want leading whitspace,
1730
1730
1731
1731
while ( pos < end ) {
1732
- pos ++ ;
1733
1732
char = text . charCodeAt ( pos ) ;
1734
1733
if ( char === CharacterCodes . openBrace ) {
1735
1734
break ;
@@ -1754,6 +1753,7 @@ namespace ts {
1754
1753
else if ( ! isWhiteSpaceSingleLine ( char ) ) {
1755
1754
firstNonWhitespace = pos ;
1756
1755
}
1756
+ pos ++ ;
1757
1757
}
1758
1758
1759
1759
return firstNonWhitespace === - 1 ? SyntaxKind . JsxTextAllWhiteSpaces : SyntaxKind . JsxText ;
Original file line number Diff line number Diff line change 1572
1572
}
1573
1573
1574
1574
export interface JsxText extends Node {
1575
- kind : SyntaxKind . JsxText ;
1575
+ kind : SyntaxKind . JsxText ,
1576
+ containsOnlyWhiteSpaces : boolean ,
1576
1577
parent ?: JsxElement ;
1577
1578
}
1578
1579
You can’t perform that action at this time.
0 commit comments