refactor: follow gh-50257 JSX.IntrinsicClassAttributes logic (#50271)

This commit is contained in:
Jack Works
2022-08-12 00:32:31 +08:00
committed by GitHub
parent 9189e42b1c
commit 075ee3d4b6

View File

@@ -27614,16 +27614,15 @@ namespace ts {
if (!isErrorType(intrinsicClassAttribs)) {
const typeParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(intrinsicClassAttribs.symbol);
const hostClassType = getReturnTypeOfSignature(sig);
let libraryManagedAttributeType: Type | undefined;
if (typeParams && typeParams.length === 1) {
let libraryManagedAttributeType: Type;
if (typeParams) {
// apply JSX.IntrinsicClassElements<hostClassType, ...>
const inferredArgs = fillMissingTypeArguments([hostClassType], typeParams, getMinTypeArgumentCount(typeParams), isInJSFile(context));
libraryManagedAttributeType = instantiateType(intrinsicClassAttribs, createTypeMapper(typeParams, inferredArgs));
}
else if (typeParams) libraryManagedAttributeType = undefined;
// or JSX.IntrinsicClassElements has no generics.
else libraryManagedAttributeType = intrinsicClassAttribs;
if (libraryManagedAttributeType) {
apparentAttributesType = intersectTypes(libraryManagedAttributeType, apparentAttributesType);
}
apparentAttributesType = intersectTypes(libraryManagedAttributeType, apparentAttributesType);
}
const intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context);