@@ -917,11 +917,25 @@ namespace ts {
917917 }
918918 }
919919
920+ export function isPossiblyTypeArgumentPosition ( token : Node , sourceFile : SourceFile , checker : TypeChecker ) : boolean {
921+ const info = getPossibleTypeArgumentsInfo ( token , sourceFile ) ;
922+ return info !== undefined && ( isPartOfTypeNode ( info . called ) ||
923+ getPossibleGenericSignatures ( info . called , info . nTypeArguments , checker ) . length !== 0 ||
924+ isPossiblyTypeArgumentPosition ( info . called , sourceFile , checker ) ) ;
925+ }
926+
927+ export function getPossibleGenericSignatures ( called : Expression , typeArgumentCount : number , checker : TypeChecker ) : ReadonlyArray < Signature > {
928+ const type = checker . getTypeAtLocation ( called ) ! ; // TODO: GH#18217
929+ const signatures = isNewExpression ( called . parent ) ? type . getConstructSignatures ( ) : type . getCallSignatures ( ) ;
930+ return signatures . filter ( candidate => ! ! candidate . typeParameters && candidate . typeParameters . length >= typeArgumentCount ) ;
931+ }
932+
920933 export interface PossibleTypeArgumentInfo {
921934 readonly called : Identifier ;
922935 readonly nTypeArguments : number ;
923936 }
924- export function isPossiblyTypeArgumentPosition ( tokenIn : Node , sourceFile : SourceFile ) : PossibleTypeArgumentInfo | undefined {
937+ // Get info for an expression like `f <` that may be the start of type arguments.
938+ export function getPossibleTypeArgumentsInfo ( tokenIn : Node , sourceFile : SourceFile ) : PossibleTypeArgumentInfo | undefined {
925939 let token : Node | undefined = tokenIn ;
926940 // This function determines if the node could be type argument position
927941 // Since during editing, when type argument list is not complete,
0 commit comments