Skip to content

Commit

Permalink
Make removeASTLocation take Standardized
Browse files Browse the repository at this point in the history
  • Loading branch information
Davilarek committed Jun 30, 2024
1 parent 75f11cd commit c53d194
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/converter.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { ParseResult } from "@babel/parser";
import { File, Identifier, ImportDeclaration, ImportSpecifier, MemberExpression, NewExpression, Statement, callExpression, identifier, memberExpression, newExpression, stringLiteral } from "@babel/types";
import { File, Identifier, ImportDeclaration, ImportSpecifier, MemberExpression, NewExpression, Standardized, Statement, callExpression, identifier, memberExpression, newExpression, stringLiteral } from "@babel/types";
import { NonFunctionType, getKeyValue, myPackageName } from "./utils.js";
import { IModImplementation } from "./api/ModImplementation";
import { addCode } from "./api/RuntimeGenerators.js";
import { IMPLEMENTATION_STORES_PATH_REQ, IMPLEMENTATION_STORES_PATH_SOURCE, IMPLEMENTATION_STORES_PATH_VAR_NAME } from "./constants.js";

function removeASTLocation(ast: Statement[] | Statement) {
function removeASTLocation(ast: Standardized[] | Standardized) {
if (Array.isArray(ast)) {
ast.forEach(a => removeASTLocation(a));
}
Expand Down Expand Up @@ -134,7 +134,7 @@ export default async function (ast: ParseResult<File>, targetedDiscordModApiLibr
const trueObj = deepFind<NewExpression>(element, newExpressionPath);
console.log(trueObj);
if (trueObj != undefined && importAliasMap.find(x => x.codeName == (trueObj.callee as Identifier).name) !== undefined) {
removeASTLocation(trueObj as unknown as Statement);
removeASTLocation(trueObj);
const importedInternalName = importAliasMap.find(x => x.codeName == (trueObj.callee as Identifier).name)!.internalName;
const propDesc = Object.getOwnPropertyDescriptor(targetedDiscordModApiLibrary.default, importedInternalName as keyof IModImplementation);
if (!propDesc)
Expand Down Expand Up @@ -177,7 +177,7 @@ export default async function (ast: ParseResult<File>, targetedDiscordModApiLibr
const trueObj = deepFind<MemberExpression>(element, memberExpressionPath);
console.log(trueObj);
if (trueObj != undefined && importAliasMap.find(x => x.codeName == (trueObj.object as Identifier).name) !== undefined) {
removeASTLocation(trueObj as unknown as Statement);
removeASTLocation(trueObj);
const importedInternalName = importAliasMap.find(x => x.codeName == (trueObj.object as Identifier).name)!.internalName;
const propDesc = Object.getOwnPropertyDescriptor(targetedDiscordModApiLibrary.default, importedInternalName as keyof IModImplementation);
if (!propDesc)
Expand Down

0 comments on commit c53d194

Please sign in to comment.