@@ -917,11 +917,25 @@ namespace ts {
917
917
}
918
918
}
919
919
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
+
920
933
export interface PossibleTypeArgumentInfo {
921
934
readonly called : Identifier ;
922
935
readonly nTypeArguments : number ;
923
936
}
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 {
925
939
let token : Node | undefined = tokenIn ;
926
940
// This function determines if the node could be type argument position
927
941
// Since during editing, when type argument list is not complete,
0 commit comments