@@ -731,7 +731,7 @@ export class Resolver extends DiagnosticEmitter {
731
731
732
732
// infer generic call if type arguments have been omitted
733
733
if ( prototype . is ( CommonFlags . Generic ) ) {
734
- let resolvedTypeArguments = this . inferGenericTypesArguments (
734
+ let resolvedTypeArguments = this . inferGenericTypeArguments (
735
735
node ,
736
736
prototype ,
737
737
prototype . typeParameterNodes ,
@@ -751,7 +751,7 @@ export class Resolver extends DiagnosticEmitter {
751
751
return this . resolveFunction ( prototype , null , new Map ( ) , reportMode ) ;
752
752
}
753
753
754
- inferGenericTypesArguments (
754
+ private inferGenericTypeArguments (
755
755
node : CallExpression | NewExpression ,
756
756
prototype : FunctionPrototype ,
757
757
typeParameterNodes : TypeParameterNode [ ] | null ,
@@ -3679,15 +3679,28 @@ export class Resolver extends DiagnosticEmitter {
3679
3679
3680
3680
// Resolve type arguments if generic
3681
3681
if ( prototype . is ( CommonFlags . Generic ) ) {
3682
- resolvedTypeArguments = this . resolveTypeArguments ( // reports
3683
- assert ( prototype . typeParameterNodes ) , // must be present if generic
3684
- typeArgumentNodes ,
3685
- flow ,
3686
- ctxElement ,
3687
- ctxTypes , // update
3688
- reportNode ,
3689
- reportMode
3690
- ) ;
3682
+
3683
+ // if no type arguments are provided, try to infer them from the constructor call
3684
+ if ( ! typeArgumentNodes && prototype . constructorPrototype && flow ) {
3685
+ resolvedTypeArguments = this . inferGenericTypeArguments (
3686
+ reportNode as NewExpression ,
3687
+ prototype . constructorPrototype ,
3688
+ prototype . typeParameterNodes ,
3689
+ flow ,
3690
+ ) ;
3691
+ } else {
3692
+ // resolve them from the provided type argument nodes
3693
+ resolvedTypeArguments = this . resolveTypeArguments ( // reports
3694
+ assert ( prototype . typeParameterNodes ) , // must be present if generic
3695
+ typeArgumentNodes ,
3696
+ flow ,
3697
+ ctxElement ,
3698
+ ctxTypes , // update
3699
+ reportNode ,
3700
+ reportMode
3701
+ ) ;
3702
+ }
3703
+
3691
3704
if ( ! resolvedTypeArguments ) return null ;
3692
3705
3693
3706
// Otherwise make sure that no type arguments have been specified
0 commit comments