Skip to content

Commit 5eb9fd0

Browse files
Yui Tmhegazy
Yui T
authored andcommitted
getApparentType of the propsType
1 parent 07b4857 commit 5eb9fd0

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
@@ -13467,13 +13467,16 @@ namespace ts {
1346713467
return _jsxElementChildrenPropertyName;
1346813468
}
1346913469

13470-
function createIntersectionOfApparentTypeOfJsxPropsType(propsType: Type): Type {
13471-
if (propsType && propsType.flags & TypeFlags.Intersection) {
13472-
const propsApprentType: Type[] = [];
13473-
for (const t of (<UnionOrIntersectionType>propsType).types) {
13474-
propsApprentType.push(getApparentType(t));
13470+
function getApparentTypeOfJsxPropsType(propsType: Type): Type {
13471+
if (propsType) {
13472+
if (propsType.flags & TypeFlags.Intersection) {
13473+
const propsApprentType: Type[] = [];
13474+
for (const t of (<UnionOrIntersectionType>propsType).types) {
13475+
propsApprentType.push(getApparentType(t));
13476+
}
13477+
return getIntersectionType(propsApprentType);
1347513478
}
13476-
return getIntersectionType(propsApprentType);
13479+
return getApparentType(propsType);
1347713480
}
1347813481
return propsType;
1347913482
}
@@ -13498,7 +13501,7 @@ namespace ts {
1349813501
if (callSignature !== unknownSignature) {
1349913502
const callReturnType = callSignature && getReturnTypeOfSignature(callSignature);
1350013503
let paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0]));
13501-
paramType = createIntersectionOfApparentTypeOfJsxPropsType(paramType);
13504+
paramType = getApparentTypeOfJsxPropsType(paramType);
1350213505
if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) {
1350313506
// Intersect in JSX.IntrinsicAttributes if it exists
1350413507
const intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes);
@@ -13537,7 +13540,7 @@ namespace ts {
1353713540
for (const candidate of candidatesOutArray) {
1353813541
const callReturnType = getReturnTypeOfSignature(candidate);
1353913542
let paramType = callReturnType && (candidate.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(candidate.parameters[0]));
13540-
paramType = createIntersectionOfApparentTypeOfJsxPropsType(paramType);
13543+
paramType = getApparentTypeOfJsxPropsType(paramType);
1354113544
if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) {
1354213545
let shouldBeCandidate = true;
1354313546
for (const attribute of openingLikeElement.attributes.properties) {

0 commit comments

Comments
 (0)