getApparentType of the propsType

This commit is contained in:
Yui T 2017-05-11 22:40:21 -07:00
parent 705771d874
commit 84f419b533

View File

@ -13548,13 +13548,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;
}
@ -13579,7 +13582,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);
@ -13618,7 +13621,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) {