@@ -731,7 +731,7 @@ export class Resolver extends DiagnosticEmitter {
731731
732732 // infer generic call if type arguments have been omitted
733733 if ( prototype . is ( CommonFlags . Generic ) ) {
734- let resolvedTypeArguments = this . inferGenericTypesArguments (
734+ let resolvedTypeArguments = this . inferGenericTypeArguments (
735735 node ,
736736 prototype ,
737737 prototype . typeParameterNodes ,
@@ -751,7 +751,7 @@ export class Resolver extends DiagnosticEmitter {
751751 return this . resolveFunction ( prototype , null , new Map ( ) , reportMode ) ;
752752 }
753753
754- inferGenericTypesArguments (
754+ private inferGenericTypeArguments (
755755 node : CallExpression | NewExpression ,
756756 prototype : FunctionPrototype ,
757757 typeParameterNodes : TypeParameterNode [ ] | null ,
@@ -3679,15 +3679,28 @@ export class Resolver extends DiagnosticEmitter {
36793679
36803680 // Resolve type arguments if generic
36813681 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+
36913704 if ( ! resolvedTypeArguments ) return null ;
36923705
36933706 // Otherwise make sure that no type arguments have been specified
0 commit comments