@@ -752,7 +752,7 @@ export class Resolver extends DiagnosticEmitter {
752
752
}
753
753
754
754
private inferGenericTypeArguments (
755
- node : CallExpression | NewExpression ,
755
+ node : Expression ,
756
756
prototype : FunctionPrototype ,
757
757
typeParameterNodes : TypeParameterNode [ ] | null ,
758
758
ctxFlow : Flow ,
@@ -776,7 +776,20 @@ export class Resolver extends DiagnosticEmitter {
776
776
777
777
let parameterNodes = prototype . functionTypeNode . parameters ;
778
778
let numParameters = parameterNodes . length ;
779
- let argumentNodes = node . args ;
779
+
780
+ let argumentNodes : Expression [ ] ;
781
+ switch ( node . kind ) {
782
+ case NodeKind . Call :
783
+ argumentNodes = ( < CallExpression > node ) . args ;
784
+ break ;
785
+ case NodeKind . New :
786
+ argumentNodes = ( < NewExpression > node ) . args ;
787
+ break ;
788
+ default :
789
+ assert ( false ) ;
790
+ return null ;
791
+ }
792
+
780
793
let numArguments = argumentNodes . length ;
781
794
782
795
// infer types with generic components while updating contextual types
@@ -3681,10 +3694,10 @@ export class Resolver extends DiagnosticEmitter {
3681
3694
if ( prototype . is ( CommonFlags . Generic ) ) {
3682
3695
3683
3696
// if no type arguments are provided, try to infer them from the constructor call
3684
- if ( ! typeArgumentNodes && prototype . constructorPrototype && flow ) {
3697
+ if ( ! typeArgumentNodes && prototype . constructorPrototype && flow && ctxTypes . size == 0 ) {
3685
3698
resolvedTypeArguments = this . inferGenericTypeArguments (
3686
3699
reportNode as NewExpression ,
3687
- prototype . constructorPrototype ,
3700
+ prototype . constructorPrototype ! ,
3688
3701
prototype . typeParameterNodes ,
3689
3702
flow ,
3690
3703
) ;
0 commit comments