File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import ts from "typescript" ;
2- import { DependencyGraph } from "./graph" ;
32import { globalTypeChecker , globalContext } from "." ;
4- import { hashSymbol , hashNode } from "./utils" ;
3+ import { hashSymbolOrNode } from "./utils" ;
54
65export const handleGet = (
76 node : ts . CallExpression ,
87 transformList : Map < ts . Node , ts . Node >
98) => {
109 // hash and move type argument to argument
11- const symbol = globalTypeChecker
12- . getTypeAtLocation ( node . typeArguments ! [ 0 ] )
13- . getSymbol ( ) ;
1410 const argument = ts . factory . createStringLiteral (
15- symbol ? hashSymbol ( symbol ) : hashNode ( node . typeArguments ! [ 0 ] )
11+ hashSymbolOrNode ( node . typeArguments ! [ 0 ] )
1612 ) ;
1713 const newNode = ts . factory . updateCallExpression (
1814 node ,
@@ -38,12 +34,7 @@ export const getFactoryDependencies = (factory: ts.Expression) => {
3834 . getSymbol ( ) ;
3935 if ( symbol && symbol === getSymbol ) {
4036 const classOrInterface = node . typeArguments ! [ 0 ] ;
41- const symbol = globalTypeChecker
42- . getTypeAtLocation ( classOrInterface )
43- . getSymbol ( ) ;
44- const hash = symbol
45- ? hashSymbol ( symbol )
46- : hashNode ( node . typeArguments ! [ 0 ] ) ;
37+ const hash = hashSymbolOrNode ( node . typeArguments ! [ 0 ] ) ;
4738 dependencies . push ( hash ) ;
4839 }
4940 }
Original file line number Diff line number Diff line change 11import ts from "typescript" ;
22import { globalContext , globalTypeChecker } from "." ;
3- import { hashNode , hashSymbol } from "./utils" ;
3+ import { hashSymbolOrNode } from "./utils" ;
44
55export const defaultFactoryTemplate = (
66 className : string ,
@@ -132,10 +132,7 @@ export const factoryWrapperTemplate = (factory: ts.Expression) => {
132132 . getSymbol ( ) ;
133133 if ( symbol && symbol === getSymbol ) {
134134 const classOrInterface = node . typeArguments ! [ 0 ] ;
135- const classOrInterfaceSymbol = globalTypeChecker . getTypeAtLocation ( classOrInterface ) . getSymbol ( )
136- const hash = classOrInterfaceSymbol
137- ? hashSymbol ( classOrInterfaceSymbol )
138- : hashNode ( classOrInterface ) ;
135+ const hash = hashSymbolOrNode ( classOrInterface ) ;
139136 const newNode = ts . factory . createCallExpression (
140137 ts . factory . createIdentifier ( "get" ) ,
141138 undefined ,
Original file line number Diff line number Diff line change @@ -35,3 +35,9 @@ export const hashNode = (node: ts.Node) => {
3535
3636 return hash ;
3737} ;
38+
39+ export const hashSymbolOrNode = ( node : ts . Node ) => {
40+ const type = globalTypeChecker . getTypeAtLocation ( node ) ;
41+ const symbol = type . getSymbol ( ) ;
42+ return symbol ? hashSymbol ( symbol ) : hashNode ( node ) ;
43+ }
You can’t perform that action at this time.
0 commit comments