Skip to content

Commit ba2c791

Browse files
committed
refact: fix type issues
1 parent ae84c27 commit ba2c791

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/register.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type TSNode from "ts-node";
1+
import TSNode from "ts-node";
22
import type { REGISTER_INSTANCE } from "ts-node";
33
import ts from "typescript";
44
import transformer from "./transformer";
@@ -7,11 +7,18 @@ import transformer from "./transformer";
77
// region: Helpers
88
/* ****************************************************************************************************************** */
99

10+
type PluginExtended = ts.PluginImport & {
11+
transform?: string;
12+
after?: boolean;
13+
before?: boolean;
14+
afterDeclarations?: boolean;
15+
};
16+
1017
function getProjectTransformerConfig(pcl: ts.ParsedCommandLine) {
11-
const plugins = pcl.options.plugins as Record<string, string>[] | undefined;
18+
const plugins = pcl.options.plugins as PluginExtended[];
1219
if (!plugins) return;
1320

14-
const res: { afterDeclarations?: Record<string, string>; before?: Record<string, string> } = {};
21+
const res: { afterDeclarations?: PluginExtended; before?: PluginExtended } = {};
1522
for (const plugin of plugins) {
1623
if (plugin.transform === "typescript-transform-paths" && !plugin.after)
1724
res[plugin.afterDeclarations ? "afterDeclarations" : "before"] = plugin;
@@ -22,8 +29,8 @@ function getProjectTransformerConfig(pcl: ts.ParsedCommandLine) {
2229

2330
function getTransformers(
2431
program?: ts.Program,
25-
beforeConfig?: Record<string, string>,
26-
afterDeclarationsConfig?: Record<string, string>,
32+
beforeConfig?: PluginExtended,
33+
afterDeclarationsConfig?: PluginExtended,
2734
): ts.CustomTransformers {
2835
return {
2936
...(beforeConfig && { before: [transformer(program, beforeConfig)] }),

0 commit comments

Comments
 (0)