Skip to content

Commit

Permalink
getApparentType of the propsType
Browse files Browse the repository at this point in the history
  • Loading branch information
Yui T authored and mhegazy committed May 12, 2017
1 parent 07b4857 commit 5eb9fd0
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/compiler/checker.ts
Expand Up @@ -13467,13 +13467,16 @@ namespace ts {
return _jsxElementChildrenPropertyName;
}

function createIntersectionOfApparentTypeOfJsxPropsType(propsType: Type): Type {
if (propsType && propsType.flags & TypeFlags.Intersection) {
const propsApprentType: Type[] = [];
for (const t of (<UnionOrIntersectionType>propsType).types) {
propsApprentType.push(getApparentType(t));
function getApparentTypeOfJsxPropsType(propsType: Type): Type {
if (propsType) {
if (propsType.flags & TypeFlags.Intersection) {
const propsApprentType: Type[] = [];
for (const t of (<UnionOrIntersectionType>propsType).types) {
propsApprentType.push(getApparentType(t));
}
return getIntersectionType(propsApprentType);
}
return getIntersectionType(propsApprentType);
return getApparentType(propsType);
}
return propsType;
}
Expand All @@ -13498,7 +13501,7 @@ namespace ts {
if (callSignature !== unknownSignature) {
const callReturnType = callSignature && getReturnTypeOfSignature(callSignature);
let paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0]));
paramType = createIntersectionOfApparentTypeOfJsxPropsType(paramType);
paramType = getApparentTypeOfJsxPropsType(paramType);
if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) {
// Intersect in JSX.IntrinsicAttributes if it exists
const intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes);
Expand Down Expand Up @@ -13537,7 +13540,7 @@ namespace ts {
for (const candidate of candidatesOutArray) {
const callReturnType = getReturnTypeOfSignature(candidate);
let paramType = callReturnType && (candidate.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(candidate.parameters[0]));
paramType = createIntersectionOfApparentTypeOfJsxPropsType(paramType);
paramType = getApparentTypeOfJsxPropsType(paramType);
if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) {
let shouldBeCandidate = true;
for (const attribute of openingLikeElement.attributes.properties) {
Expand Down

0 comments on commit 5eb9fd0

Please sign in to comment.