Skip to content

Commit f61875f

Browse files
committed
refactor: change type signature of cli plugin
1 parent b5951bf commit f61875f

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

lib/plugin/compiler-plugin.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,24 @@ function isFilenameMatched(patterns: string[], filename: string): boolean {
1111
export const before: (
1212
options: Record<string, any> | undefined,
1313
program: ts.Program,
14-
) => (ctx: ts.TransformationContext) => ts.Transformer<any> = (
14+
) => ts.TransformerFactory<ts.SourceFile> | ts.CustomTransformerFactory = (
1515
options,
1616
program,
1717
) => {
1818
const mergedOption = mergePluginOptions(options);
1919

20-
return (ctx: ts.TransformationContext): ts.Transformer<any> => {
21-
return (sf: ts.SourceFile) => {
20+
return (ctx) => {
21+
return (sourceFile) => {
2222
if (
2323
isFilenameMatched(
2424
mergedOption.interfaceFilenameSuffix as string[],
25-
sf.fileName,
25+
sourceFile.fileName,
2626
)
2727
) {
28-
return httpInterfaceVisitor.visit(sf, ctx, program);
28+
return httpInterfaceVisitor.visit(sourceFile, ctx, program);
2929
}
3030

31-
return sf;
31+
return sourceFile;
3232
};
3333
};
3434
};

lib/plugin/visitors/http-interface.visitor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class HttpInterfaceVisitor {
4040
sourceFile: ts.SourceFile,
4141
ctx: ts.TransformationContext,
4242
program: ts.Program,
43-
): ts.Node {
43+
): ts.SourceFile {
4444
this.importSet.clear();
4545
const factory = ctx.factory;
4646
const typeChecker = program.getTypeChecker();
@@ -61,7 +61,7 @@ export class HttpInterfaceVisitor {
6161
return ts.visitEachChild(node, visitNode, ctx);
6262
};
6363

64-
return ts.visitNode(sourceFile, visitNode);
64+
return ts.visitNode(sourceFile, visitNode) as ts.SourceFile;
6565
}
6666

6767
private updateSourceFile(

0 commit comments

Comments
 (0)