Skip to content

Commit

Permalink
fix: add missing no symbol handle
Browse files Browse the repository at this point in the history
  • Loading branch information
suphon-t committed Jan 3, 2024
1 parent 95d43e4 commit fda270f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
17 changes: 10 additions & 7 deletions src/walk/3-modify-get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ export const handleGet = (
transformList: Map<ts.Node, ts.Node>
) => {
// hash and move type argument to argument
const symbol = globalTypeChecker.getTypeAtLocation(node.typeArguments![0]).getSymbol()
const symbol = globalTypeChecker
.getTypeAtLocation(node.typeArguments![0])
.getSymbol();
const argument = ts.factory.createStringLiteral(
symbol ? hashSymbol(
symbol
) : hashNode(node.typeArguments![0])
symbol ? hashSymbol(symbol) : hashNode(node.typeArguments![0])
);
const newNode = ts.factory.updateCallExpression(
node,
Expand All @@ -38,9 +38,12 @@ export const getFactoryDependencies = (factory: ts.Expression) => {
.getSymbol();
if (symbol && symbol === getSymbol) {
const classOrInterface = node.typeArguments![0];
const hash = hashSymbol(
globalTypeChecker.getTypeAtLocation(classOrInterface).getSymbol()!
);
const symbol = globalTypeChecker
.getTypeAtLocation(classOrInterface)
.getSymbol();
const hash = symbol
? hashSymbol(symbol)
: hashNode(node.typeArguments![0]);
dependencies.push(hash);
}
}
Expand Down
9 changes: 5 additions & 4 deletions src/walk/source-templates.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ts from "typescript";
import { globalContext, globalTypeChecker } from ".";
import { hashSymbol } from "./utils";
import { hashNode, hashSymbol } from "./utils";

export const defaultFactoryTemplate = (
className: string,
Expand Down Expand Up @@ -132,9 +132,10 @@ export const factoryWrapperTemplate = (factory: ts.Expression) => {
.getSymbol();
if (symbol && symbol === getSymbol) {
const classOrInterface = node.typeArguments![0];
const hash = hashSymbol(
globalTypeChecker.getTypeAtLocation(classOrInterface).getSymbol()!
);
const classOrInterfaceSymbol = globalTypeChecker.getTypeAtLocation(classOrInterface).getSymbol()
const hash = classOrInterfaceSymbol
? hashSymbol(classOrInterfaceSymbol)
: hashNode(classOrInterface);
const newNode = ts.factory.createCallExpression(
ts.factory.createIdentifier("get"),
undefined,
Expand Down

0 comments on commit fda270f

Please sign in to comment.