From 18731879cfcf44d1e32fa7c58cc950290f5b169f Mon Sep 17 00:00:00 2001 From: Jake Son Date: Sun, 22 Oct 2023 10:21:48 +0900 Subject: [PATCH 1/2] refactor: change type signature of cli plugin --- lib/plugin/compiler-plugin.ts | 12 ++++++------ lib/plugin/visitors/http-interface.visitor.ts | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/plugin/compiler-plugin.ts b/lib/plugin/compiler-plugin.ts index f825c10..bec2460 100644 --- a/lib/plugin/compiler-plugin.ts +++ b/lib/plugin/compiler-plugin.ts @@ -11,24 +11,24 @@ function isFilenameMatched(patterns: string[], filename: string): boolean { export const before: ( options: Record | undefined, program: ts.Program, -) => (ctx: ts.TransformationContext) => ts.Transformer = ( +) => ts.TransformerFactory | ts.CustomTransformerFactory = ( options, program, ) => { const mergedOption = mergePluginOptions(options); - return (ctx: ts.TransformationContext): ts.Transformer => { - return (sf: ts.SourceFile) => { + return (ctx) => { + return (sourceFile) => { if ( isFilenameMatched( mergedOption.interfaceFilenameSuffix as string[], - sf.fileName, + sourceFile.fileName, ) ) { - return httpInterfaceVisitor.visit(sf, ctx, program); + return httpInterfaceVisitor.visit(sourceFile, ctx, program); } - return sf; + return sourceFile; }; }; }; diff --git a/lib/plugin/visitors/http-interface.visitor.ts b/lib/plugin/visitors/http-interface.visitor.ts index 17d7c5d..da2dd9a 100644 --- a/lib/plugin/visitors/http-interface.visitor.ts +++ b/lib/plugin/visitors/http-interface.visitor.ts @@ -40,7 +40,7 @@ export class HttpInterfaceVisitor { sourceFile: ts.SourceFile, ctx: ts.TransformationContext, program: ts.Program, - ): ts.Node { + ): ts.SourceFile { this.importSet.clear(); const factory = ctx.factory; const typeChecker = program.getTypeChecker(); @@ -61,7 +61,7 @@ export class HttpInterfaceVisitor { return ts.visitEachChild(node, visitNode, ctx); }; - return ts.visitNode(sourceFile, visitNode); + return ts.visitNode(sourceFile, visitNode) as ts.SourceFile; } private updateSourceFile( From 3bba62230608ff66c142ba61b30b384935b38313 Mon Sep 17 00:00:00 2001 From: Jake Son Date: Sun, 22 Oct 2023 10:28:30 +0900 Subject: [PATCH 2/2] chore: exclude example director from test coverage --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index 079ddd5..f4fe23c 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,4 +1,4 @@ sonar.projectKey=r2don_nest-http-interface sonar.organization=r2don sonar.javascript.lcov.reportPaths=coverage/lcov.info -sonar.coverage.exclusions=**.spec.ts,plugin.js +sonar.coverage.exclusions=**.spec.ts,plugin.js,example/**/*