From 882722d3b716de05fb8231d345bb6ff75540f170 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20My=C5=9Bliwiec?= Date: Wed, 5 Jul 2023 10:17:14 +0200 Subject: [PATCH] fix(plugin): use unknown to fix ts incompatibility issues --- .../interfaces/readonly-visitor.interface.ts | 12 +++++++----- lib/compiler/plugins/plugin-metadata-generator.ts | 9 +++++---- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/compiler/interfaces/readonly-visitor.interface.ts b/lib/compiler/interfaces/readonly-visitor.interface.ts index c422243bb..9017ca33f 100644 --- a/lib/compiler/interfaces/readonly-visitor.interface.ts +++ b/lib/compiler/interfaces/readonly-visitor.interface.ts @@ -9,9 +9,11 @@ export type DeepPluginMeta = export interface ReadonlyVisitor { key: string; typeImports: Record; - visit( - program: Program, - sf: SourceFile, - ): void; - collect(): Record>; + + // Using unknown here because of the potential + // incompatibility between a locally installed TypeScript version + // and the one used by the CLI. + + visit(program: unknown, sf: unknown): unknown; + collect(): Record>; } diff --git a/lib/compiler/plugins/plugin-metadata-generator.ts b/lib/compiler/plugins/plugin-metadata-generator.ts index 2478fdd53..b1da54c8c 100644 --- a/lib/compiler/plugins/plugin-metadata-generator.ts +++ b/lib/compiler/plugins/plugin-metadata-generator.ts @@ -125,9 +125,7 @@ export class PluginMetadataGenerator { ) { for (const sourceFile of programRef.getSourceFiles()) { if (!sourceFile.isDeclarationFile) { - visitors.forEach((visitor) => - visitor.visit(programRef, sourceFile), - ); + visitors.forEach((visitor) => visitor.visit(programRef, sourceFile)); } } @@ -138,7 +136,10 @@ export class PluginMetadataGenerator { > = {}; visitors.forEach((visitor) => { - collectedMetadata[visitor.key] = visitor.collect(); + collectedMetadata[visitor.key] = visitor.collect() as Record< + string, + Array<[ts.CallExpression, DeepPluginMeta]> + >; typeImports = { ...typeImports, ...visitor.typeImports,