From 29d0d4b872240849808da45c2f2e9a056cf8bd92 Mon Sep 17 00:00:00 2001 From: Kamil Mysliwiec Date: Tue, 27 Dec 2022 11:39:19 +0100 Subject: [PATCH] Revert "chore(): remove method deprecated " --- lib/compiler/plugins-loader.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/compiler/plugins-loader.ts b/lib/compiler/plugins-loader.ts index 1e5de8eb0..07f82feb7 100644 --- a/lib/compiler/plugins-loader.ts +++ b/lib/compiler/plugins-loader.ts @@ -1,5 +1,6 @@ import { join } from 'path'; import * as ts from 'typescript'; +import { isObject } from 'util'; import { CLI_ERRORS } from '../ui'; const PLUGIN_ENTRY_FILENAME = 'plugin'; @@ -30,7 +31,7 @@ export interface MultiNestCompilerPlugins { export class PluginsLoader { public load(plugins: PluginEntry[] = []): MultiNestCompilerPlugins { const pluginNames = plugins.map((entry) => - entry ? (entry as PluginAndOptions)?.name : (entry as string) + isObject(entry) ? (entry as PluginAndOptions).name : (entry as string), ); const nodeModulePaths = [ join(process.cwd(), 'node_modules'), @@ -62,7 +63,9 @@ export class PluginsLoader { if (!plugin.before && !plugin.after && !plugin.afterDeclarations) { throw new Error(CLI_ERRORS.WRONG_PLUGIN(pluginNames[index])); } - const options = plugins[index]?.options || {}; + const options = isObject(plugins[index]) + ? (plugins[index] as PluginAndOptions).options || {} + : {}; plugin.before && beforeHooks.push(plugin.before.bind(plugin.before, options)); plugin.after && afterHooks.push(plugin.after.bind(plugin.after, options));