@@ -20,7 +20,7 @@ const {
2020 findParent,
2121 getCallSignatureDeclaration,
2222 getCallee,
23- getCalleeDeclarations ,
23+ getCalleeDeclaration ,
2424 getJSDocThrowsTags,
2525 getJSDocThrowsTagTypes,
2626 toFlattenedTypeArray,
@@ -455,8 +455,8 @@ debugger;
455455 ) ;
456456 } ) ;
457457
458- describe ( 'getCalleeDeclarations ' , ( ) => {
459- test ( 'get declaration of a function calls' , ( t ) => {
458+ describe ( 'getCalleeDeclaration ' , ( ) => {
459+ test . only ( 'get declaration of a function calls' , ( t ) => {
460460 const { ast, services, sourceCode } = parse ( `
461461// foo declaration
462462function foo() {}
@@ -500,31 +500,31 @@ obj.baz = 42;
500500
501501 t . assert . ok (
502502 sourceCode
503- . getCommentsBefore (
504- services . tsNodeToESTreeNodeMap
505- . get ( getCalleeDeclarations ( services , callExpression ) [ 0 ] )
506- )
507- . some ( ( { value } ) => value . includes ( 'foo declaration' ) ) ,
503+ . getCommentsBefore (
504+ services . tsNodeToESTreeNodeMap
505+ . get ( getCalleeDeclaration ( services , callExpression ) )
506+ )
507+ . some ( ( { value } ) => value . includes ( 'foo declaration' ) ) ,
508508 '`foo()` must return the declaration of `foo`' ,
509509 ) ;
510510
511511 t . assert . ok (
512512 sourceCode
513- . getCommentsBefore (
514- services . tsNodeToESTreeNodeMap
515- . get ( getCalleeDeclarations ( services , memberExpression ) [ 0 ] ) ,
516- )
517- . some ( ( { value } ) => value . includes ( 'bar declaration' ) ) ,
513+ . getCommentsBefore (
514+ services . tsNodeToESTreeNodeMap
515+ . get ( getCalleeDeclaration ( services , memberExpression ) ) ,
516+ )
517+ . some ( ( { value } ) => value . includes ( 'bar declaration' ) ) ,
518518 '`const value = obj.bar` must return the declaration of `obj.bar`' ,
519519 ) ;
520520
521521 t . assert . ok (
522522 sourceCode
523- . getCommentsBefore (
524- services . tsNodeToESTreeNodeMap
525- . get ( getCalleeDeclarations ( services , assignmentExpression ) [ 0 ] ) ,
526- )
527- . some ( ( { value } ) => value . includes ( 'baz declaration' ) ) ,
523+ . getCommentsBefore (
524+ services . tsNodeToESTreeNodeMap
525+ . get ( getCalleeDeclaration ( services , assignmentExpression ) ) ,
526+ )
527+ . some ( ( { value } ) => value . includes ( 'baz declaration' ) ) ,
528528 '`obj.baz = 42` must return the declaration of `obj.baz`' ,
529529 ) ;
530530 } ) ;
@@ -561,13 +561,13 @@ obj.baz = 42;
561561 const assignmentExpression = map . get ( AST_NODE_TYPES . AssignmentExpression ) ;
562562
563563 t . assert . equal (
564- getCalleeDeclarations ( services , memberExpression ) . length ,
565- 0
564+ getCalleeDeclaration ( services , memberExpression ) ,
565+ null
566566 ) ;
567567
568568 t . assert . equal (
569- getCalleeDeclarations ( services , assignmentExpression ) . length ,
570- 0
569+ getCalleeDeclaration ( services , assignmentExpression ) ,
570+ null
571571 ) ;
572572 } ) ;
573573
579579
580580 const identifier = getFirstFoundIdentifier ( ast , 'a' ) ;
581581 t . assert . equal (
582- getCalleeDeclarations ( services , identifier ) . length ,
583- 0 ,
584- 'non-callable node should return nothing ' ,
582+ getCalleeDeclaration ( services , identifier ) ,
583+ null ,
584+ 'non-callable node should return null ' ,
585585 ) ;
586586 } ) ;
587587 } ) ;
0 commit comments