1
- import type { SgRoot , SgNode , Edit } from "@codemod.com/jssg-types/main" ;
1
+ import type { SgRoot , SgNode , Edit , TypesMap , Kinds } from "@codemod.com/jssg-types/main" ;
2
2
import type JS from "@codemod.com/jssg-types/langs/javascript" ;
3
3
import { getNodeImportStatements } from "@nodejs/codemod-utils/ast-grep/import-statement" ;
4
4
import { getNodeRequireCalls } from "@nodejs/codemod-utils/ast-grep/require-call" ;
@@ -81,7 +81,7 @@ function getPromisifiedBindings(root: SgRoot<JS>, existingBindings: string[]): s
81
81
) ;
82
82
}
83
83
84
- function findCryptoCalls ( rootNode : SgNode < JS > , bindings : string [ ] ) {
84
+ function findCryptoCalls ( rootNode : SgNode < JS > , bindings : string [ ] ) : SgNode < JS > [ ] {
85
85
return bindings
86
86
. flatMap ( bindingName => rootNode . findAll ( {
87
87
rule : {
@@ -99,8 +99,8 @@ function getText(node: SgNode<JS> | undefined): string | null {
99
99
}
100
100
101
101
function getModuleStatements ( root : SgRoot < JS > , moduleName : string ) : SgNode < JS > [ ] {
102
- const importStatements = getNodeImportStatements ( root , moduleName ) ;
103
- const requireCalls = getNodeRequireCalls ( root , moduleName ) ;
102
+ const importStatements = getNodeImportStatements ( root as unknown as SgRoot , moduleName ) ;
103
+ const requireCalls = getNodeRequireCalls ( root as unknown as SgRoot , moduleName ) ;
104
104
return [ ...importStatements , ...requireCalls ] as unknown as SgNode < JS > [ ] ;
105
105
}
106
106
@@ -110,7 +110,7 @@ function resolveBindings(statements: SgNode<JS>[], paths: string | string[]): st
110
110
111
111
return statements . flatMap ( stmt =>
112
112
pathArray
113
- . map ( path => resolveBindingPath ( stmt , path ) )
113
+ . map ( path => resolveBindingPath ( stmt as unknown as SgNode < TypesMap , Kinds < TypesMap > > , path ) )
114
114
. filter ( Boolean )
115
115
) ;
116
116
}
0 commit comments