Use constraint for default default value if possible (#28222)

This commit is contained in:
Wesley Wigham
2018-10-30 14:55:30 -07:00
committed by GitHub
parent 4cfff8962c
commit e2436f331a
6 changed files with 70 additions and 1 deletions

View File

@@ -7653,7 +7653,7 @@ namespace ts {
// If a type parameter does not have a default type, or if the default type
// is a forward reference, the empty object type is used.
for (let i = numTypeArguments; i < numTypeParameters; i++) {
result[i] = getDefaultTypeArgumentType(isJavaScriptImplicitAny);
result[i] = getConstraintFromTypeParameter(typeParameters![i]) || getDefaultTypeArgumentType(isJavaScriptImplicitAny);
}
for (let i = numTypeArguments; i < numTypeParameters; i++) {
const mapper = createTypeMapper(typeParameters!, result);