Skip to content

Commit 84f419b

Browse files
author
Yui T
committed
getApparentType of the propsType
1 parent 705771d commit 84f419b

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/compiler/checker.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13548,13 +13548,16 @@ namespace ts {
1354813548
return _jsxElementChildrenPropertyName;
1354913549
}
1355013550

13551-
function createIntersectionOfApparentTypeOfJsxPropsType(propsType: Type): Type {
13552-
if (propsType && propsType.flags & TypeFlags.Intersection) {
13553-
const propsApprentType: Type[] = [];
13554-
for (const t of (<UnionOrIntersectionType>propsType).types) {
13555-
propsApprentType.push(getApparentType(t));
13551+
function getApparentTypeOfJsxPropsType(propsType: Type): Type {
13552+
if (propsType) {
13553+
if (propsType.flags & TypeFlags.Intersection) {
13554+
const propsApprentType: Type[] = [];
13555+
for (const t of (<UnionOrIntersectionType>propsType).types) {
13556+
propsApprentType.push(getApparentType(t));
13557+
}
13558+
return getIntersectionType(propsApprentType);
1355613559
}
13557-
return getIntersectionType(propsApprentType);
13560+
return getApparentType(propsType);
1355813561
}
1355913562
return propsType;
1356013563
}
@@ -13579,7 +13582,7 @@ namespace ts {
1357913582
if (callSignature !== unknownSignature) {
1358013583
const callReturnType = callSignature && getReturnTypeOfSignature(callSignature);
1358113584
let paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0]));
13582-
paramType = createIntersectionOfApparentTypeOfJsxPropsType(paramType);
13585+
paramType = getApparentTypeOfJsxPropsType(paramType);
1358313586
if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) {
1358413587
// Intersect in JSX.IntrinsicAttributes if it exists
1358513588
const intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes);
@@ -13618,7 +13621,7 @@ namespace ts {
1361813621
for (const candidate of candidatesOutArray) {
1361913622
const callReturnType = getReturnTypeOfSignature(candidate);
1362013623
let paramType = callReturnType && (candidate.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(candidate.parameters[0]));
13621-
paramType = createIntersectionOfApparentTypeOfJsxPropsType(paramType);
13624+
paramType = getApparentTypeOfJsxPropsType(paramType);
1362213625
if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) {
1362313626
let shouldBeCandidate = true;
1362413627
for (const attribute of openingLikeElement.attributes.properties) {

0 commit comments

Comments
 (0)