Skip to content

Commit

Permalink
fix: remove unnecessary return value
Browse files Browse the repository at this point in the history
  • Loading branch information
Hajime-san committed Apr 10, 2023
1 parent 81b67a2 commit b2c1cd9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 22 deletions.
4 changes: 0 additions & 4 deletions src/resolve_util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ export const getModuleSpecifier = <T extends HasModuleSpecifierNode>(args: {
imports: ReturnType<typeof resolvedModules>;
}): {
moduleSpecifier: ModuleSpecifierReturnType<T>;
node: T;
} => {
const { node, imports } = args;
let moduleSpecifier: ModuleSpecifierReturnType<T>;
Expand All @@ -82,7 +81,6 @@ export const getModuleSpecifier = <T extends HasModuleSpecifierNode>(args: {
return {
// @ts-ignore Variable 'X' is used before being assigned. deno-ts(2454)
moduleSpecifier,
node,
};
};

Expand All @@ -91,7 +89,6 @@ export const getExpressionArguments = (args: {
imports: ReturnType<typeof resolvedModules>;
}): {
expressionArguments: Array<string>;
node: ts.CallExpression;
} => {
const { node, imports } = args;
const expressionArguments = node.arguments.map((argument) => {
Expand All @@ -103,7 +100,6 @@ export const getExpressionArguments = (args: {

return {
expressionArguments,
node,
};
};

Expand Down
3 changes: 0 additions & 3 deletions src/resolve_util_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ Deno.test('getModuleSpecifier', async (t) => {
}),
{
moduleSpecifier: './ComponentA.tsx',
node: localSourceImportDeclaration,
},
);
});
Expand All @@ -154,7 +153,6 @@ Deno.test('getModuleSpecifier', async (t) => {
}),
{
moduleSpecifier: 'react',
node: externalLibImportDeclaration,
},
);
});
Expand All @@ -171,7 +169,6 @@ Deno.test('getExpressionArguments', async (t) => {
}),
{
expressionArguments: ['./ComponentE.tsx'],
node: localCallExpression,
},
);
});
Expand Down
30 changes: 15 additions & 15 deletions src/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@ const transformModuleSpecifier = (
ts.isCallExpression(newNode) &&
newNode.expression.kind === ts.SyntaxKind.ImportKeyword
) {
const { expressionArguments, node } = getExpressionArguments({
const { expressionArguments } = getExpressionArguments({
node: newNode,
imports,
});
return context.factory.updateCallExpression(
node,
node.expression,
node.typeArguments,
newNode,
newNode.expression,
newNode.typeArguments,
expressionArguments.map((argument) =>
context.factory.createStringLiteral(argument)
),
);
}
// Transform "aggregating modules"
if (ts.isExportDeclaration(newNode)) {
const { moduleSpecifier, node } = getModuleSpecifier({
const { moduleSpecifier } = getModuleSpecifier({
node: newNode,
imports,
});
Expand All @@ -46,12 +46,12 @@ const transformModuleSpecifier = (
// export { foo } from "./foo.(ts|tsx|d.ts)"
if (moduleSpecifier) {
return context.factory.updateExportDeclaration(
node,
node.modifiers,
node.isTypeOnly,
node.exportClause,
newNode,
newNode.modifiers,
newNode.isTypeOnly,
newNode.exportClause,
context.factory.createStringLiteral(moduleSpecifier),
node.assertClause,
newNode.assertClause,
);
}
//
Expand All @@ -64,16 +64,16 @@ const transformModuleSpecifier = (
// to
// import { bar } from "./bar.(ts|tsx|d.ts)"
if (ts.isImportDeclaration(newNode)) {
const { moduleSpecifier, node } = getModuleSpecifier({
const { moduleSpecifier } = getModuleSpecifier({
node: newNode,
imports,
});
return context.factory.updateImportDeclaration(
node,
node.modifiers,
node.importClause,
newNode,
newNode.modifiers,
newNode.importClause,
context.factory.createStringLiteral(moduleSpecifier),
node.assertClause,
newNode.assertClause,
);
}
return newNode;
Expand Down

0 comments on commit b2c1cd9

Please sign in to comment.