@@ -13275,7 +13275,7 @@ namespace ts {
13275
13275
const parent = openingLikeElement.parent.kind === SyntaxKind.JsxElement ?
13276
13276
openingLikeElement.parent as JsxElement : undefined;
13277
13277
let containsSynthesizedJsxChildren = false;
13278
- // Comment
13278
+ // We have to check that openingElement of the parent is the one we are visiting as this may not be true for selfClosingElement
13279
13279
if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) {
13280
13280
// Error if there is a attribute named "children" and children element.
13281
13281
// This is because children element will overwrite the value from attributes
@@ -13287,7 +13287,11 @@ namespace ts {
13287
13287
const childrenPropSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, jsxChildrenPropertyName);
13288
13288
const childrenTypes: Type[] = [];
13289
13289
for (const child of (parent as JsxElement).children) {
13290
- childrenTypes.push(child.kind === SyntaxKind.JsxText ? stringType : checkExpression(child));
13290
+ // In React, JSX text that contains only whitespaces will be ignored so we don't want to type-check that
13291
+ // because then type of children property will have constituent of string type.
13292
+ if (child.kind !== SyntaxKind.JsxTextAllWhiteSpaces) {
13293
+ childrenTypes.push(child.kind === SyntaxKind.JsxText ? stringType : checkExpression(child as Expression, checkMode));
13294
+ }
13291
13295
}
13292
13296
childrenPropSymbol.type = getUnionType(childrenTypes, /*subtypeReduction*/ false);
13293
13297
attributesTable.set(jsxChildrenPropertyName, childrenPropSymbol);
@@ -17099,13 +17103,6 @@ namespace ts {
17099
17103
return cache ? checkExpressionCached(node) : checkExpression(node);
17100
17104
}
17101
17105
17102
- // Checks an expression and returns its type. The contextualMapper parameter serves two purposes: When
17103
- // contextualMapper is not undefined and not equal to the identityMapper function object it indicates that the
17104
- // expression is being inferentially typed (section 4.15.2 in spec) and provides the type mapper to use in
17105
- // conjunction with the generic contextual type. When contextualMapper is equal to the identityMapper function
17106
- // object, it serves as an indicator that all contained function and arrow expressions should be considered to
17107
- // have the wildcard function type; this form of type check is used during overload resolution to exclude
17108
- // contextually typed function and arrow expressions in the initial phase.
17109
17106
function checkExpression(node: Expression | QualifiedName, checkMode?: CheckMode): Type {
17110
17107
let type: Type;
17111
17108
if (node.kind === SyntaxKind.QualifiedName) {
0 commit comments