11import * as Path from 'path' ;
2- import type {
3- ClassDeclaration ,
4- TSEnumDeclaration ,
5- TSInterfaceDeclaration ,
6- TSModuleBlock ,
7- TSModuleDeclaration ,
8- TSTypeAliasDeclaration ,
9- } from '@typescript-eslint/types/dist/ts-estree' ;
10- import type { AST , TSESTreeOptions } from '@typescript-eslint/typescript-estree' ;
2+ import type { AST , TSESTreeOptions , TSESTree } from '@typescript-eslint/typescript-estree' ;
113import { AST_NODE_TYPES } from '@typescript-eslint/typescript-estree' ;
124import type { Logger } from 'winston' ;
135import type { ResolutionContext } from '../resolution/ResolutionContext' ;
@@ -43,7 +35,10 @@ export class ClassLoader {
4335 * @param declaration A class declaration.
4436 * @param fileName The file name of the current class.
4537 */
46- public getSuperClassName ( declaration : ClassDeclaration , fileName : string ) : GenericallyTyped < string > | undefined {
38+ public getSuperClassName (
39+ declaration : TSESTree . ClassDeclaration ,
40+ fileName : string ,
41+ ) : GenericallyTyped < string > | undefined {
4742 if ( ! declaration . superClass ) {
4843 return ;
4944 }
@@ -69,7 +64,10 @@ export class ClassLoader {
6964 * @param declaration An interface declaration.
7065 * @param fileName The file name of the current class.
7166 */
72- public getSuperInterfaceNames ( declaration : TSInterfaceDeclaration , fileName : string ) : GenericallyTyped < string > [ ] {
67+ public getSuperInterfaceNames (
68+ declaration : TSESTree . TSInterfaceDeclaration ,
69+ fileName : string ,
70+ ) : GenericallyTyped < string > [ ] {
7371 return < GenericallyTyped < string > [ ] > ( declaration . extends || [ ] )
7472 // eslint-disable-next-line array-callback-return
7573 . map ( extendsExpression => {
@@ -92,7 +90,10 @@ export class ClassLoader {
9290 * @param declaration A class declaration.
9391 * @param fileName The file name of the current class.
9492 */
95- public getClassInterfaceNames ( declaration : ClassDeclaration , fileName : string ) : GenericallyTyped < string > [ ] {
93+ public getClassInterfaceNames (
94+ declaration : TSESTree . ClassDeclaration ,
95+ fileName : string ,
96+ ) : GenericallyTyped < string > [ ] {
9697 const interfaceNames : GenericallyTyped < string > [ ] = [ ] ;
9798 if ( declaration . implements ) {
9899 for ( const implement of declaration . implements ) {
@@ -154,7 +155,7 @@ export class ClassLoader {
154155 * such as a type alias or enum.
155156 */
156157 public async loadClassDeclarationFromAst < CI extends boolean , CT extends boolean > (
157- ast : AST < TSESTreeOptions > | TSModuleBlock ,
158+ ast : AST < TSESTreeOptions > | TSESTree . TSModuleBlock ,
158159 targetString : string ,
159160 classReference : ClassReference ,
160161 considerInterfaces : CI ,
@@ -367,7 +368,7 @@ export class ClassLoader {
367368 if ( enumMember . id . type === AST_NODE_TYPES . Identifier && enumMember . id . name === enumKey &&
368369 enumMember . initializer && enumMember . initializer . type === AST_NODE_TYPES . Literal ) {
369370 // Expose the enum entry as type alias
370- const typeNode : TSTypeAliasDeclaration = {
371+ const typeNode : TSESTree . TSTypeAliasDeclaration = {
371372 type : AST_NODE_TYPES . TSTypeAliasDeclaration ,
372373 id : {
373374 type : AST_NODE_TYPES . Identifier ,
@@ -411,9 +412,9 @@ export class ClassLoader {
411412
412413 // Check if the export assignment refers to a namespace
413414 if ( exportAssignment && typeof exportAssignment === 'string' && exportAssignment in declaredNamespaces ) {
414- const namespace : TSModuleDeclaration = declaredNamespaces [ exportAssignment ] ;
415+ const namespace : TSESTree . TSModuleDeclaration = declaredNamespaces [ exportAssignment ] ;
415416 return this . loadClassDeclarationFromAst (
416- < TSModuleBlock > namespace . body ,
417+ < TSESTree . TSModuleBlock > namespace . body ,
417418 targetString ,
418419 classReference ,
419420 considerInterfaces ,
@@ -430,7 +431,7 @@ export class ClassLoader {
430431 * @param classDeclaration A class or interface declaration.
431432 */
432433 public collectGenericTypes (
433- classDeclaration : ClassDeclaration | TSInterfaceDeclaration | TSTypeAliasDeclaration ,
434+ classDeclaration : TSESTree . ClassDeclaration | TSESTree . TSInterfaceDeclaration | TSESTree . TSTypeAliasDeclaration ,
434435 ) : GenericTypes {
435436 const genericTypes : GenericTypes = { } ;
436437 if ( classDeclaration . typeParameters ) {
@@ -533,27 +534,27 @@ export class ClassLoader {
533534 public getClassElements (
534535 packageName : string ,
535536 fileName : string ,
536- ast : AST < TSESTreeOptions > | TSModuleBlock ,
537+ ast : AST < TSESTreeOptions > | TSESTree . TSModuleBlock ,
537538 ) : ClassElements {
538- const exportedClasses : Record < string , ClassDeclaration > = { } ;
539- const exportedInterfaces : Record < string , TSInterfaceDeclaration > = { } ;
540- const exportedTypes : Record < string , TSTypeAliasDeclaration > = { } ;
541- const exportedEnums : Record < string , TSEnumDeclaration > = { } ;
542- const exportedNamespaces : Record < string , TSModuleDeclaration > = { } ;
539+ const exportedClasses : Record < string , TSESTree . ClassDeclaration > = { } ;
540+ const exportedInterfaces : Record < string , TSESTree . TSInterfaceDeclaration > = { } ;
541+ const exportedTypes : Record < string , TSESTree . TSTypeAliasDeclaration > = { } ;
542+ const exportedEnums : Record < string , TSESTree . TSEnumDeclaration > = { } ;
543+ const exportedNamespaces : Record < string , TSESTree . TSModuleDeclaration > = { } ;
543544 const exportedImportedElements : Record < string , ClassReference > = { } ;
544545 const exportedImportedAll : { packageName : string ; fileName : string ; fileNameReferenced : string } [ ] = [ ] ;
545546 const exportedImportedAllNamed :
546547 Record < string , { packageName : string ; fileName : string ; fileNameReferenced : string } > = { } ;
547548 const exportedUnknowns : Record < string , string > = { } ;
548- const declaredClasses : Record < string , ClassDeclaration > = { } ;
549- const declaredInterfaces : Record < string , TSInterfaceDeclaration > = { } ;
550- const declaredTypes : Record < string , TSTypeAliasDeclaration > = { } ;
551- const declaredEnums : Record < string , TSEnumDeclaration > = { } ;
552- const declaredNamespaces : Record < string , TSModuleDeclaration > = { } ;
549+ const declaredClasses : Record < string , TSESTree . ClassDeclaration > = { } ;
550+ const declaredInterfaces : Record < string , TSESTree . TSInterfaceDeclaration > = { } ;
551+ const declaredTypes : Record < string , TSESTree . TSTypeAliasDeclaration > = { } ;
552+ const declaredEnums : Record < string , TSESTree . TSEnumDeclaration > = { } ;
553+ const declaredNamespaces : Record < string , TSESTree . TSModuleDeclaration > = { } ;
553554 const importedElements : Record < string , ClassReference > = { } ;
554555 const importedElementsAllNamed :
555556 Record < string , { packageName : string ; fileName : string ; fileNameReferenced : string } > = { } ;
556- let exportAssignment : string | ClassDeclaration | undefined ;
557+ let exportAssignment : string | TSESTree . ClassDeclaration | undefined ;
557558
558559 for ( const statement of ast . body ) {
559560 if ( statement . type === AST_NODE_TYPES . ExportNamedDeclaration ) {
@@ -685,15 +686,15 @@ export interface ClassLoaderArgs {
685686 */
686687export interface ClassElements {
687688 // Classes that have been declared in a file via `export class A`
688- exportedClasses : Record < string , ClassDeclaration > ;
689+ exportedClasses : Record < string , TSESTree . ClassDeclaration > ;
689690 // Interfaces that have been declared in a file via `export interface A`
690- exportedInterfaces : Record < string , TSInterfaceDeclaration > ;
691+ exportedInterfaces : Record < string , TSESTree . TSInterfaceDeclaration > ;
691692 // Types that have been declared in a file via `export type A = ...`
692- exportedTypes : Record < string , TSTypeAliasDeclaration > ;
693+ exportedTypes : Record < string , TSESTree . TSTypeAliasDeclaration > ;
693694 // Enums that have been declared in a file via `export enum A {...}`
694- exportedEnums : Record < string , TSEnumDeclaration > ;
695+ exportedEnums : Record < string , TSESTree . TSEnumDeclaration > ;
695696 // Namespaces that have been declared in a file via `export namespace A { ... }`
696- exportedNamespaces : Record < string , TSModuleDeclaration > ;
697+ exportedNamespaces : Record < string , TSESTree . TSModuleDeclaration > ;
697698 // Elements that have been exported via `export { A as B } from "b"`
698699 exportedImportedElements : Record < string , ClassReference > ;
699700 // Exports via `export * from "b"`
@@ -703,19 +704,19 @@ export interface ClassElements {
703704 // Things that have been exported via `export {A as B}`, where the target is not known
704705 exportedUnknowns : Record < string , string > ;
705706 // Classes that have been declared in a file via `declare class A`
706- declaredClasses : Record < string , ClassDeclaration > ;
707+ declaredClasses : Record < string , TSESTree . ClassDeclaration > ;
707708 // Interfaces that have been declared in a file via `declare interface A`
708- declaredInterfaces : Record < string , TSInterfaceDeclaration > ;
709+ declaredInterfaces : Record < string , TSESTree . TSInterfaceDeclaration > ;
709710 // Types that have been declared in a file via `declare type A = ...`
710- declaredTypes : Record < string , TSTypeAliasDeclaration > ;
711+ declaredTypes : Record < string , TSESTree . TSTypeAliasDeclaration > ;
711712 // Enums that have been declared in a file via `declare enum A {...}`
712- declaredEnums : Record < string , TSEnumDeclaration > ;
713+ declaredEnums : Record < string , TSESTree . TSEnumDeclaration > ;
713714 // Namespaces that have been declared in a file via `declare namespace A { ... }`
714- declaredNamespaces : Record < string , TSModuleDeclaration > ;
715+ declaredNamespaces : Record < string , TSESTree . TSModuleDeclaration > ;
715716 // Elements that are imported from elsewhere via `import {A} from ''`
716717 importedElements : Record < string , ClassReference > ;
717718 // Elements that are imported from elsewhere via `import * as A from ''`
718719 importedElementsAllNamed : Record < string , { packageName : string ; fileName : string ; fileNameReferenced : string } > ;
719720 // Element exported via `export = ...`
720- exportAssignment : string | ClassDeclaration | undefined ;
721+ exportAssignment : string | TSESTree . ClassDeclaration | undefined ;
721722}
0 commit comments