11import { ESLintUtils , TSESLint , TSESTree } from '@typescript-eslint/utils' ;
2- import * as tsutils from 'ts-api-utils' ;
32import ts from 'typescript' ;
43import { couldBeFunction } from './could-be-function' ;
54import { couldBeType as tsutilsEtcCouldBeType } from './could-be-type' ;
@@ -18,7 +17,7 @@ export function getTypeServices<
1817 name : string | RegExp ,
1918 qualified ?: { name : RegExp } ,
2019 ) : boolean => {
21- const type = getType ( node ) ;
20+ const type = getTypeAtLocation ( node ) ;
2221 return tsutilsEtcCouldBeType (
2322 type ,
2423 name ,
@@ -56,19 +55,14 @@ export function getTypeServices<
5655 ) ;
5756 } ;
5857
59- const getType = ( node : TSESTree . Node ) : ts . Type => {
60- return getTypeAtLocation ( node ) ;
61- } ;
62-
6358 return {
6459 couldBeBehaviorSubject : ( node : TSESTree . Node ) =>
6560 couldBeType ( node , 'BehaviorSubject' ) ,
66- couldBeError : ( node : TSESTree . Node ) => couldBeType ( node , 'Error' ) ,
6761 couldBeFunction : ( node : TSESTree . Node ) => {
6862 if ( isArrowFunctionExpression ( node ) || isFunctionDeclaration ( node ) ) {
6963 return true ;
7064 }
71- return couldBeFunction ( getType ( node ) ) ;
65+ return couldBeFunction ( getTypeAtLocation ( node ) ) ;
7266 } ,
7367 couldBeMonoTypeOperatorFunction : ( node : TSESTree . Node ) =>
7468 couldBeType ( node , 'MonoTypeOperatorFunction' ) ,
@@ -79,10 +73,5 @@ export function getTypeServices<
7973 couldReturnObservable : ( node : TSESTree . Node ) =>
8074 couldReturnType ( node , 'Observable' ) ,
8175 couldReturnType,
82- getType,
83- isAny : ( node : TSESTree . Node ) => tsutils . isIntrinsicAnyType ( getType ( node ) ) ,
84- isReferenceType : ( node : TSESTree . Node ) => tsutils . isTypeReference ( getType ( node ) ) ,
85- isUnknown : ( node : TSESTree . Node ) => tsutils . isIntrinsicUnknownType ( getType ( node ) ) ,
86- typeChecker,
8776 } ;
8877}
0 commit comments