|
7 | 7 | */ |
8 | 8 |
|
9 | 9 | import remapping, { SourceMapInput } from '@ampproject/remapping'; |
10 | | -import { PluginObj, parseSync, transformFromAstAsync, types } from '@babel/core'; |
| 10 | +import { NodePath, PluginItem, parseSync, transformFromAstAsync, types } from '@babel/core'; |
11 | 11 | import assert from 'node:assert'; |
12 | 12 | import { workerData } from 'node:worker_threads'; |
13 | 13 | import { assertIsError } from '../../utils/error'; |
@@ -144,26 +144,25 @@ async function loadLocalizeTools(): Promise<LocalizeUtilityModule> { |
144 | 144 | async function createI18nPlugins(locale: string, translation: Record<string, unknown> | undefined) { |
145 | 145 | const { Diagnostics, makeEs2015TranslatePlugin } = await loadLocalizeTools(); |
146 | 146 |
|
147 | | - const plugins: PluginObj[] = []; |
| 147 | + const plugins: PluginItem[] = []; |
148 | 148 | const diagnostics = new Diagnostics(); |
149 | 149 |
|
150 | 150 | plugins.push( |
151 | | - // eslint-disable-next-line @typescript-eslint/no-explicit-any |
152 | | - makeEs2015TranslatePlugin(diagnostics, (translation || {}) as any, { |
| 151 | + makeEs2015TranslatePlugin(diagnostics, translation || {}, { |
153 | 152 | missingTranslation: translation === undefined ? 'ignore' : missingTranslation, |
154 | | - }), |
| 153 | + }) as unknown as PluginItem, |
155 | 154 | ); |
156 | 155 |
|
157 | 156 | // Create a plugin to replace the locale specifier constant inject by the build system with the actual specifier |
158 | | - plugins.push({ |
| 157 | + plugins.push(() => ({ |
159 | 158 | visitor: { |
160 | | - StringLiteral(path) { |
| 159 | + StringLiteral(path: NodePath<types.StringLiteral>) { |
161 | 160 | if (path.node.value === '___NG_LOCALE_INSERT___') { |
162 | 161 | path.replaceWith(types.stringLiteral(locale)); |
163 | 162 | } |
164 | 163 | }, |
165 | 164 | }, |
166 | | - }); |
| 165 | + })); |
167 | 166 |
|
168 | 167 | return { diagnostics, plugins }; |
169 | 168 | } |
|
0 commit comments