@@ -514,8 +514,6 @@ function tryGetReturnTypeOfFunction(symbol: Symbol, type: Type, checker: TypeChe
514514 return undefined ;
515515}
516516
517-
518-
519517/** @internal */
520518export function getDefinitionAndBoundSpan ( program : Program , sourceFile : SourceFile , position : number ) : DefinitionInfoAndBoundSpan | undefined {
521519 const definitions = getDefinitionAtPosition ( program , sourceFile , position ) ;
@@ -541,17 +539,17 @@ export function getDefinitionAndBoundSpan(program: Program, sourceFile: SourceFi
541539}
542540
543541function getInferrableDefinitionIndex ( definitions : readonly DefinitionInfo [ ] , node : Node , program : Program ) : number | undefined {
544- const TYPEY_SET = new Set ( [ SyntaxKind . InterfaceDeclaration , SyntaxKind . TypeAliasDeclaration ] )
542+ const TYPEY_SET = new Set ( [ SyntaxKind . InterfaceDeclaration , SyntaxKind . TypeAliasDeclaration ] ) ;
545543
546544 const mainIsTypey = getUsageNodeKind ( node ) === SyntaxKind . TypeReference ;
547- const optionNodes = definitions ?. map ( def => findNodeFromSpan ( program . getSourceFile ( def . fileName ) , def . textSpan ) ! )
548- const definitionsAreTypey = optionNodes . map ( ( node ) => TYPEY_SET . has ( node ?. parent ?. kind ?? undefined ) )
545+ const optionNodes = definitions ?. map ( def => findNodeFromSpan ( program . getSourceFile ( def . fileName ) , def . textSpan ) ! ) ;
546+ const definitionsAreTypey = optionNodes . map ( node => TYPEY_SET . has ( node ?. parent ?. kind ?? undefined ) ) ;
549547
550- return definitionsAreTypey . filter ( ( def ) => def === mainIsTypey ) . length === 1 ? definitionsAreTypey . indexOf ( mainIsTypey ) : undefined ;
548+ return definitionsAreTypey . filter ( def => def === mainIsTypey ) . length === 1 ? definitionsAreTypey . indexOf ( mainIsTypey ) : undefined ;
551549}
552550
553551function getUsageNodeKind ( node : Node ) : SyntaxKind {
554- return node . kind === SyntaxKind . QualifiedName || node . kind === SyntaxKind . Identifier ? getUsageNodeKind ( node . parent ) : node . kind ;
552+ return node . kind === SyntaxKind . QualifiedName || node . kind === SyntaxKind . Identifier ? getUsageNodeKind ( node . parent ) : node . kind ;
555553}
556554
557555function findNodeFromSpan ( sourceFile : SourceFile | undefined , span : TextSpan ) : Node | undefined {
@@ -570,8 +568,6 @@ function findNodeFromSpan(sourceFile: SourceFile | undefined, span: TextSpan): N
570568 return sourceFile ? visit ( sourceFile ) : undefined ;
571569}
572570
573-
574-
575571// At 'x.foo', see if the type of 'x' has an index signature, and if so find its declarations.
576572function getDefinitionInfoForIndexSignatures ( node : Node , checker : TypeChecker ) : DefinitionInfo [ ] | undefined {
577573 return mapDefined ( checker . getIndexInfosAtLocation ( node ) , info => info . declaration && createDefinitionFromSignatureDeclaration ( checker , info . declaration ) ) ;
0 commit comments