From 075ee3d4b60f557c95ccb540e730536f945d81ab Mon Sep 17 00:00:00 2001 From: Jack Works Date: Fri, 12 Aug 2022 00:32:31 +0800 Subject: [PATCH] refactor: follow gh-50257 JSX.IntrinsicClassAttributes logic (#50271) --- src/compiler/checker.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d3f4581ee0c..7781994bf28 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -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 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);