From 1e806cea01a08641a2514e99707ea259df67d95a Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Mon, 1 May 2017 11:53:13 -0700 Subject: [PATCH] For React Component class, we fill in missing type parameter and instantiate the constructor signature with the new type arguments. --- src/compiler/checker.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1e483eb80cd..e1ed2f4fa1f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -13438,7 +13438,18 @@ namespace ts { } } - return getUnionType(map(signatures, getReturnTypeOfSignature), /*subtypeReduction*/ true); + const instantiatedSignatures = []; + for (const signature of signatures) { + if (signature.typeParameters) { + const typeArguments = fillMissingTypeArguments(/*typeArguments*/ undefined, signature.typeParameters, /*minTypeArgumentCount*/ 0); + instantiatedSignatures.push(getSignatureInstantiation(signature, typeArguments)); + } + else { + instantiatedSignatures.push(signature); + } + } + + return getUnionType(map(instantiatedSignatures, getReturnTypeOfSignature), /*subtypeReduction*/ true); } /**