versacompiler 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,6 +3,7 @@ import { env } from 'node:process';
3
3
  import { logger } from '../servicios/logger.js';
4
4
  import { getModuleSubPath } from '../utils/module-resolver.js';
5
5
  import { analyzeAndFormatMultipleErrors } from './error-reporter.js';
6
+ import { getOptimizedAliasPath, getOptimizedModulePath, } from './module-resolution-optimizer.js';
6
7
  import { parser } from './parser.js';
7
8
  // Módulos built-in de Node.js que no deben ser resueltos
8
9
  const NODE_BUILTIN_MODULES = new Set([
@@ -118,50 +119,77 @@ export async function replaceAliasImportStatic(file, code) {
118
119
  if (!moduleRequest)
119
120
  continue; // Skip if moduleRequest is undefined
120
121
  let newPath = null;
121
- let transformed = false;
122
- // 1. PRIMERO: Verificar si es un módulo excluido (prioridad máxima)
122
+ let transformed = false; // 1. PRIMERO: Verificar si es un módulo excluido (prioridad máxima)
123
123
  if (!transformed && isExternalModule(moduleRequest, pathAlias)) {
124
124
  try {
125
- const modulePath = getModuleSubPath(moduleRequest, file);
126
- if (modulePath === null) {
127
- // Si getModuleSubPath retorna null, significa que es un módulo excluido
128
- // No transformar y continuar con el siguiente import
125
+ // Usar el sistema optimizado primero
126
+ const optimizedPath = await getOptimizedModulePath(moduleRequest, file);
127
+ if (optimizedPath === null) {
128
+ // Si el optimizador retorna null, significa que es un módulo excluido
129
129
  continue;
130
130
  }
131
- if (modulePath) {
132
- newPath = modulePath;
131
+ if (optimizedPath) {
132
+ newPath = optimizedPath;
133
133
  transformed = true;
134
134
  }
135
+ else {
136
+ // Fallback al sistema anterior
137
+ const modulePath = getModuleSubPath(moduleRequest, file);
138
+ if (modulePath === null) {
139
+ continue;
140
+ }
141
+ if (modulePath) {
142
+ newPath = modulePath;
143
+ transformed = true;
144
+ }
145
+ }
135
146
  }
136
147
  catch (error) {
137
148
  if (env.VERBOSE === 'true')
138
149
  logger.warn(`Error resolviendo módulo ${moduleRequest}: ${error instanceof Error ? error.message : String(error)}`);
139
150
  }
140
- }
141
- // 2. Si no es módulo externo/excluido, verificar si es un alias conocido
151
+ } // 2. Si no es módulo externo/excluido, verificar si es un alias conocido
142
152
  if (!transformed) {
143
- for (const [alias] of Object.entries(pathAlias)) {
144
- const aliasPattern = alias.replace('/*', '');
145
- if (moduleRequest.startsWith(aliasPattern)) {
146
- // Reemplazar el alias con la ruta del target
147
- const relativePath = moduleRequest.replace(aliasPattern, '');
148
- // Para alias que apuntan a la raíz (como @/* -> /src/*),
149
- // solo usamos PATH_DIST + relativePath
150
- let newImportPath = path.join('/', env.PATH_DIST, relativePath);
151
- // Normalizar la ruta para eliminar ./ extra y separadores de Windows
152
- newImportPath = newImportPath
153
- .replace(/\/\.\//g, '/')
154
- .replace(/\\/g, '/');
155
- if (newImportPath.endsWith('.ts') ||
156
- newImportPath.endsWith('.vue')) {
157
- newImportPath = newImportPath.replace(/\.(ts|vue)$/, '.js');
158
- }
159
- else if (!/\.(js|mjs|css|json)$/.test(newImportPath)) {
160
- newImportPath += '.js';
153
+ // Usar el sistema optimizado de alias
154
+ const aliasPath = getOptimizedAliasPath(moduleRequest);
155
+ if (aliasPath) {
156
+ let newImportPath = aliasPath;
157
+ // Transformar extensiones
158
+ if (newImportPath.endsWith('.ts') ||
159
+ newImportPath.endsWith('.vue')) {
160
+ newImportPath = newImportPath.replace(/\.(ts|vue)$/, '.js');
161
+ }
162
+ else if (!/\.(js|mjs|css|json)$/.test(newImportPath)) {
163
+ newImportPath += '.js';
164
+ }
165
+ newPath = newImportPath;
166
+ transformed = true;
167
+ }
168
+ else {
169
+ // Fallback al sistema anterior
170
+ for (const [alias] of Object.entries(pathAlias)) {
171
+ const aliasPattern = alias.replace('/*', '');
172
+ if (moduleRequest.startsWith(aliasPattern)) {
173
+ // Reemplazar el alias con la ruta del target
174
+ const relativePath = moduleRequest.replace(aliasPattern, '');
175
+ // Para alias que apuntan a la raíz (como @/* -> /src/*),
176
+ // solo usamos PATH_DIST + relativePath
177
+ let newImportPath = path.join('/', env.PATH_DIST, relativePath);
178
+ // Normalizar la ruta para eliminar ./ extra y separadores de Windows
179
+ newImportPath = newImportPath
180
+ .replace(/\/\.\//g, '/')
181
+ .replace(/\\/g, '/');
182
+ if (newImportPath.endsWith('.ts') ||
183
+ newImportPath.endsWith('.vue')) {
184
+ newImportPath = newImportPath.replace(/\.(ts|vue)$/, '.js');
185
+ }
186
+ else if (!/\.(js|mjs|css|json)$/.test(newImportPath)) {
187
+ newImportPath += '.js';
188
+ }
189
+ newPath = newImportPath;
190
+ transformed = true;
191
+ break;
161
192
  }
162
- newPath = newImportPath;
163
- transformed = true;
164
- break;
165
193
  }
166
194
  }
167
195
  }
@@ -206,50 +234,77 @@ async function replaceAliasImportDynamic(code, _imports, file) {
206
234
  if (!moduleRequest)
207
235
  continue; // Skip if moduleRequest is undefined
208
236
  let newPath = null;
209
- let transformed = false;
210
- // 1. PRIMERO: Verificar si es un módulo excluido (prioridad máxima)
237
+ let transformed = false; // 1. PRIMERO: Verificar si es un módulo excluido (prioridad máxima)
211
238
  if (!transformed && isExternalModule(moduleRequest, pathAlias)) {
212
239
  try {
213
- const modulePath = getModuleSubPath(moduleRequest, file);
214
- if (modulePath === null) {
215
- // Si getModuleSubPath retorna null, significa que es un módulo excluido
216
- // No transformar y continuar con el siguiente import
240
+ // Usar el sistema optimizado primero
241
+ const optimizedPath = await getOptimizedModulePath(moduleRequest, file);
242
+ if (optimizedPath === null) {
243
+ // Si el optimizador retorna null, significa que es un módulo excluido
217
244
  continue;
218
245
  }
219
- if (modulePath) {
220
- newPath = modulePath;
246
+ if (optimizedPath) {
247
+ newPath = optimizedPath;
221
248
  transformed = true;
222
249
  }
250
+ else {
251
+ // Fallback al sistema anterior
252
+ const modulePath = getModuleSubPath(moduleRequest, file);
253
+ if (modulePath === null) {
254
+ continue;
255
+ }
256
+ if (modulePath) {
257
+ newPath = modulePath;
258
+ transformed = true;
259
+ }
260
+ }
223
261
  }
224
262
  catch (error) {
225
263
  if (env.VERBOSE === 'true')
226
264
  logger.warn(`Error resolviendo módulo dinámico ${moduleRequest}: ${error instanceof Error ? error.message : String(error)}`);
227
265
  }
228
- }
229
- // 2. Si no es módulo externo/excluido, verificar si es un alias conocido
266
+ } // 2. Si no es módulo externo/excluido, verificar si es un alias conocido
230
267
  if (!transformed) {
231
- for (const [alias] of Object.entries(pathAlias)) {
232
- const aliasPattern = alias.replace('/*', '');
233
- if (moduleRequest.startsWith(aliasPattern)) {
234
- // Reemplazar el alias con la ruta del target
235
- const relativePath = moduleRequest.replace(aliasPattern, '');
236
- // Para alias que apuntan a la raíz (como @/* -> /src/*),
237
- // solo usamos PATH_DIST + relativePath
238
- let newImportPath = path.join('/', pathDist, relativePath);
239
- // Normalizar la ruta para eliminar ./ extra y separadores de Windows
240
- newImportPath = newImportPath
241
- .replace(/\/\.\//g, '/')
242
- .replace(/\\/g, '/');
243
- if (newImportPath.endsWith('.ts') ||
244
- newImportPath.endsWith('.vue')) {
245
- newImportPath = newImportPath.replace(/\.(ts|vue)$/, '.js');
246
- }
247
- else if (!/\.(js|mjs|css|json)$/.test(newImportPath)) {
248
- newImportPath += '.js';
268
+ // Usar el sistema optimizado de alias
269
+ const aliasPath = getOptimizedAliasPath(moduleRequest);
270
+ if (aliasPath) {
271
+ let newImportPath = aliasPath;
272
+ // Transformar extensiones
273
+ if (newImportPath.endsWith('.ts') ||
274
+ newImportPath.endsWith('.vue')) {
275
+ newImportPath = newImportPath.replace(/\.(ts|vue)$/, '.js');
276
+ }
277
+ else if (!/\.(js|mjs|css|json)$/.test(newImportPath)) {
278
+ newImportPath += '.js';
279
+ }
280
+ newPath = newImportPath;
281
+ transformed = true;
282
+ }
283
+ else {
284
+ // Fallback al sistema anterior
285
+ for (const [alias] of Object.entries(pathAlias)) {
286
+ const aliasPattern = alias.replace('/*', '');
287
+ if (moduleRequest.startsWith(aliasPattern)) {
288
+ // Reemplazar el alias con la ruta del target
289
+ const relativePath = moduleRequest.replace(aliasPattern, '');
290
+ // Para alias que apuntan a la raíz (como @/* -> /src/*),
291
+ // solo usamos PATH_DIST + relativePath
292
+ let newImportPath = path.join('/', pathDist, relativePath);
293
+ // Normalizar la ruta para eliminar ./ extra y separadores de Windows
294
+ newImportPath = newImportPath
295
+ .replace(/\/\.\//g, '/')
296
+ .replace(/\\/g, '/');
297
+ if (newImportPath.endsWith('.ts') ||
298
+ newImportPath.endsWith('.vue')) {
299
+ newImportPath = newImportPath.replace(/\.(ts|vue)$/, '.js');
300
+ }
301
+ else if (!/\.(js|mjs|css|json)$/.test(newImportPath)) {
302
+ newImportPath += '.js';
303
+ }
304
+ newPath = newImportPath;
305
+ transformed = true;
306
+ break;
249
307
  }
250
- newPath = newImportPath;
251
- transformed = true;
252
- break;
253
308
  }
254
309
  }
255
310
  }
@@ -400,22 +455,13 @@ async function replaceAliasInStrings(code) {
400
455
  // El target puede ser un array de strings o un string
401
456
  const targetArray = Array.isArray(target) ? target : [target];
402
457
  const targetPath = targetArray[0];
403
- // Debug logs
404
- if (env.VERBOSE === 'true') {
405
- console.log(`🔍 DEBUG replaceAliasInStrings:
406
- - stringContent: "${stringContent}"
407
- - aliasPattern: "${aliasPattern}"
408
- - relativePath: "${relativePath}"
409
- - targetPath: "${targetPath}"
410
- - pathDist: "${pathDist}"`);
411
- }
412
458
  if (targetPath.startsWith('/')) {
413
459
  // Si el target empieza con /, es una ruta absoluta desde la raíz del proyecto
414
- // Remover /* del final si existe
415
- const cleanTarget = targetPath.replace('/*', '');
416
- newPath = path.join(cleanTarget, relativePath);
460
+ // Para targets como "/src/*", solo usamos PATH_DIST + relativePath
461
+ // sin incluir el directorio del target en la ruta final
462
+ newPath = path.join('/', pathDist, relativePath);
417
463
  if (env.VERBOSE === 'true') {
418
- console.log(` ✅ Ruta absoluta: cleanTarget="${cleanTarget}", newPath="${newPath}"`);
464
+ console.log(` ✅ Ruta absoluta: pathDist="${pathDist}", relativePath="${relativePath}", newPath="${newPath}"`);
419
465
  }
420
466
  }
421
467
  else {
@@ -424,22 +470,13 @@ async function replaceAliasInStrings(code) {
424
470
  .replace('./', '')
425
471
  .replace('/*', '');
426
472
  const normalizedPathDist = pathDist.replace('./', '');
427
- if (env.VERBOSE === 'true') {
428
- console.log(` 🔍 Ruta relativa: cleanTarget="${cleanTarget}", normalizedPathDist="${normalizedPathDist}"`);
429
- }
430
473
  if (cleanTarget === normalizedPathDist) {
431
474
  // Si el target es el mismo que PATH_DIST, no duplicar
432
475
  newPath = path.join('/', normalizedPathDist, relativePath);
433
- if (env.VERBOSE === 'true') {
434
- console.log(` ✅ Sin duplicación: newPath="${newPath}"`);
435
- }
436
476
  }
437
477
  else {
438
478
  // Si es diferente, usar PATH_DIST como base
439
479
  newPath = path.join('/', normalizedPathDist, cleanTarget, relativePath);
440
- if (env.VERBOSE === 'true') {
441
- console.log(` ✅ Con PATH_DIST: newPath="${newPath}"`);
442
- }
443
480
  }
444
481
  }
445
482
  // Normalizar la ruta para eliminar ./ extra y separadores de Windows
@@ -460,9 +497,6 @@ async function replaceAliasInStrings(code) {
460
497
  const escapedOriginal = fullMatch.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
461
498
  const specificRegex = new RegExp(escapedOriginal, 'g');
462
499
  resultCode = resultCode.replace(specificRegex, newFullMatch);
463
- if (env.VERBOSE === 'true') {
464
- logger.info(`Alias en string transformado: ${stringContent} -> ${newStringContent}`);
465
- }
466
500
  }
467
501
  }
468
502
  return resultCode;
@@ -1,7 +1,8 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
+ import * as process from 'node:process';
3
4
  import { env } from 'node:process';
4
- import * as ts from 'typescript';
5
+ import * as typescript from 'typescript';
5
6
  import { createUnifiedErrorMessage, parseTypeScriptErrors, } from './typescript-error-parser.js';
6
7
  import { TypeScriptWorkerManager } from './typescript-worker.js';
7
8
  /**
@@ -15,8 +16,7 @@ let configCache = {};
15
16
  */
16
17
  export const loadTypeScriptConfig = (fileName) => {
17
18
  const fileDir = path.dirname(fileName);
18
- const configPath = ts.findConfigFile(fileDir, ts.sys.fileExists, 'tsconfig.json') ||
19
- path.resolve(process.cwd(), 'tsconfig.json');
19
+ const configPath = typescript.findConfigFile(fileDir, typescript.sys.fileExists, 'tsconfig.json') || path.resolve(process.cwd(), 'tsconfig.json');
20
20
  // Usar cache si el path no ha cambiado
21
21
  if (configCache.path === configPath && configCache.options) {
22
22
  return configCache.options;
@@ -24,9 +24,9 @@ export const loadTypeScriptConfig = (fileName) => {
24
24
  let compilerOptions;
25
25
  if (configPath && fs.existsSync(configPath)) {
26
26
  try {
27
- const { config, error: configError } = ts.readConfigFile(configPath, ts.sys.readFile);
27
+ const { config, error: configError } = typescript.readConfigFile(configPath, typescript.sys.readFile);
28
28
  if (!configError) {
29
- const parsedConfig = ts.parseJsonConfigFileContent(config, ts.sys, path.dirname(configPath));
29
+ const parsedConfig = typescript.parseJsonConfigFileContent(config, typescript.sys, path.dirname(configPath));
30
30
  compilerOptions = {
31
31
  ...parsedConfig.options,
32
32
  // Asegurar opciones básicas necesarias
@@ -59,8 +59,8 @@ export const loadTypeScriptConfig = (fileName) => {
59
59
  * Obtiene las opciones por defecto del compilador TypeScript
60
60
  */
61
61
  const getDefaultCompilerOptions = () => ({
62
- target: ts.ScriptTarget.ES2020,
63
- module: ts.ModuleKind.ES2020,
62
+ target: typescript.ScriptTarget.ES2020,
63
+ module: typescript.ModuleKind.ES2020,
64
64
  lib: ['es2020', 'dom', 'dom.iterable'],
65
65
  strict: false,
66
66
  skipLibCheck: true,
@@ -70,13 +70,13 @@ const getDefaultCompilerOptions = () => ({
70
70
  isolatedModules: true,
71
71
  });
72
72
  /**
73
- * Crea una versión optimizada y serializable de las opciones del compilador TypeScript.
73
+ * Crea una versión optimizada y serializable de las opciones del compilador typescript.
74
74
  * @param options - Opciones originales del compilador
75
75
  * @returns Opciones serializables seguras para workers
76
76
  */
77
77
  const createSerializableCompilerOptions = (options) => {
78
78
  // Usar las opciones del tsconfig.json pero con optimizaciones para el worker
79
- const { target = ts.ScriptTarget.ES2020, module = ts.ModuleKind.ES2020, lib = ['es2020', 'dom', 'dom.iterable'], allowJs = true, jsx, strict = false, skipLibCheck = true, esModuleInterop = true, allowSyntheticDefaultImports = true, isolatedModules = true, } = options;
79
+ const { target = typescript.ScriptTarget.ES2020, module = typescript.ModuleKind.ES2020, lib = ['es2020', 'dom', 'dom.iterable'], allowJs = true, jsx, strict = false, skipLibCheck = true, esModuleInterop = true, allowSyntheticDefaultImports = true, isolatedModules = true, } = options;
80
80
  return {
81
81
  target,
82
82
  module,
@@ -124,13 +124,13 @@ class TypeScriptLanguageServiceHost {
124
124
  getScriptSnapshot(fileName) {
125
125
  const file = this.files.get(fileName);
126
126
  if (file) {
127
- return ts.ScriptSnapshot.fromString(file.content);
127
+ return typescript.ScriptSnapshot.fromString(file.content);
128
128
  }
129
129
  // Cache de sistema de archivos para evitar lecturas repetidas
130
130
  if (this.fileSystemCache.has(fileName)) {
131
131
  const cachedContent = this.fileSystemCache.get(fileName);
132
132
  return cachedContent
133
- ? ts.ScriptSnapshot.fromString(cachedContent)
133
+ ? typescript.ScriptSnapshot.fromString(cachedContent)
134
134
  : undefined;
135
135
  }
136
136
  // Intentar leer el archivo del sistema de archivos solo si es necesario
@@ -138,7 +138,7 @@ class TypeScriptLanguageServiceHost {
138
138
  if (fs.existsSync(fileName)) {
139
139
  const content = fs.readFileSync(fileName, 'utf-8');
140
140
  this.fileSystemCache.set(fileName, content);
141
- return ts.ScriptSnapshot.fromString(content);
141
+ return typescript.ScriptSnapshot.fromString(content);
142
142
  }
143
143
  }
144
144
  catch {
@@ -151,7 +151,7 @@ class TypeScriptLanguageServiceHost {
151
151
  return process.cwd();
152
152
  }
153
153
  getDefaultLibFileName(options) {
154
- return ts.getDefaultLibFilePath(options);
154
+ return typescript.getDefaultLibFilePath(options);
155
155
  }
156
156
  fileExists(path) {
157
157
  if (this.files.has(path))
@@ -185,7 +185,7 @@ class TypeScriptLanguageServiceHost {
185
185
  return undefined;
186
186
  }
187
187
  getNewLine() {
188
- return ts.sys.newLine;
188
+ return typescript.sys.newLine;
189
189
  }
190
190
  }
191
191
  /**
@@ -230,9 +230,8 @@ export {};`;
230
230
  }
231
231
  else {
232
232
  host.addFile(actualFileName, content);
233
- }
234
- // Crear Language Service
235
- const languageService = ts.createLanguageService(host);
233
+ } // Crear Language Service
234
+ const languageService = typescript.createLanguageService(host);
236
235
  // Verificar existencia del archivo
237
236
  if (!host.fileExists(actualFileName)) {
238
237
  return { diagnostics: [], hasErrors: false };
@@ -246,12 +245,11 @@ export {};`;
246
245
  catch {
247
246
  // Ignorar errores de diagnósticos
248
247
  return { diagnostics: [], hasErrors: false };
249
- }
250
- // Filtrado optimizado de diagnósticos
248
+ } // Filtrado optimizado de diagnósticos
251
249
  const filteredDiagnostics = allDiagnostics.filter(diag => {
252
- if (diag.category !== ts.DiagnosticCategory.Error)
250
+ if (diag.category !== typescript.DiagnosticCategory.Error)
253
251
  return false;
254
- const messageText = ts.flattenDiagnosticMessageText(diag.messageText, '\n');
252
+ const messageText = typescript.flattenDiagnosticMessageText(diag.messageText, '\n');
255
253
  // Lista optimizada de patrones a ignorar
256
254
  const ignorePatterns = [
257
255
  'Cannot find module',
@@ -277,7 +275,7 @@ export {};`;
277
275
  start: undefined,
278
276
  length: undefined,
279
277
  messageText: `Error en validación de tipos: ${error instanceof Error ? error.message : 'Error desconocido'}`,
280
- category: ts.DiagnosticCategory.Error,
278
+ category: typescript.DiagnosticCategory.Error,
281
279
  code: 0,
282
280
  },
283
281
  ],
@@ -298,7 +296,7 @@ export const validateVueTypes = (vueContent, fileName) => {
298
296
  /**
299
297
  * Precompila el código TypeScript con pipeline optimizado para máxima performance.
300
298
  * @param {string} data - El código TypeScript a precompilar.
301
- * @param {string} fileName - El nombre del archivo que contiene el código TypeScript.
299
+ * @param {string} fileName - El nombre del archivo que contiene el código typescript.
302
300
  * @returns {Promise<CompileResult>} - Un objeto con el código precompilado o un error.
303
301
  */
304
302
  export const preCompileTS = async (data, fileName) => {
@@ -308,9 +306,8 @@ export const preCompileTS = async (data, fileName) => {
308
306
  return { error: null, data: data, lang: 'ts' };
309
307
  }
310
308
  // Cargar configuración de TypeScript desde tsconfig.json
311
- const compilerOptions = loadTypeScriptConfig(fileName);
312
- // PASO 1: Transpilación rápida con detección de errores críticos
313
- const transpileResult = ts.transpileModule(data, {
309
+ const compilerOptions = loadTypeScriptConfig(fileName); // PASO 1: Transpilación rápida con detección de errores críticos
310
+ const transpileResult = typescript.transpileModule(data, {
314
311
  compilerOptions: {
315
312
  ...compilerOptions,
316
313
  noLib: true,
@@ -324,10 +321,10 @@ export const preCompileTS = async (data, fileName) => {
324
321
  // fileName,data)
325
322
  // Verificar errores críticos de sintaxis
326
323
  if (transpileResult.diagnostics?.length) {
327
- const criticalErrors = transpileResult.diagnostics.filter(diag => {
328
- if (diag.category !== ts.DiagnosticCategory.Error)
324
+ const criticalErrors = transpileResult.diagnostics.filter((diag) => {
325
+ if (diag.category !== typescript.DiagnosticCategory.Error)
329
326
  return false;
330
- const messageText = ts.flattenDiagnosticMessageText(diag.messageText, '\n');
327
+ const messageText = typescript.flattenDiagnosticMessageText(diag.messageText, '\n');
331
328
  // Ignorar errores de módulo no encontrado
332
329
  return (!messageText.includes('Cannot find module') &&
333
330
  !messageText.includes('Could not find source file') &&
@@ -379,4 +376,4 @@ export const preCompileTS = async (data, fileName) => {
379
376
  };
380
377
  }
381
378
  };
382
- //# sourceMappingURL=typescript.js.map
379
+ //# sourceMappingURL=typescript-compiler.js.map
@@ -1,4 +1,4 @@
1
- import * as ts from 'typescript';
1
+ import * as typescript from 'typescript';
2
2
  /**
3
3
  * Parsea errores de TypeScript y los convierte a un formato limpio
4
4
  * que incluye solo: archivo, mensaje, severidad y ubicación como ayuda
@@ -6,14 +6,13 @@ import * as ts from 'typescript';
6
6
  export function parseTypeScriptErrors(diagnostics, fileName, sourceCode) {
7
7
  return diagnostics.map(diagnostic => {
8
8
  // Usar el mejorador de errores para obtener mensaje detallado
9
- const enhancedMessage = enhanceErrorMessage(diagnostic, fileName, sourceCode);
10
- // Determinar la severidad
9
+ const enhancedMessage = enhanceErrorMessage(diagnostic, fileName, sourceCode); // Determinar la severidad
11
10
  let severity;
12
11
  switch (diagnostic.category) {
13
- case ts.DiagnosticCategory.Error:
12
+ case typescript.DiagnosticCategory.Error:
14
13
  severity = 'error';
15
14
  break;
16
- case ts.DiagnosticCategory.Warning:
15
+ case typescript.DiagnosticCategory.Warning:
17
16
  severity = 'warning';
18
17
  break;
19
18
  default:
@@ -67,7 +66,7 @@ function enhanceErrorMessage(diagnostic, fileName, sourceCode) {
67
66
  // Extraer el mensaje del error
68
67
  const message = typeof diagnostic.messageText === 'string'
69
68
  ? diagnostic.messageText
70
- : ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
69
+ : typescript.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
71
70
  let enhancedMessage = cleanErrorMessage(message); // Información de ubicación
72
71
  let location = `Código TS${diagnostic.code}`;
73
72
  let codeContext = '';
@@ -242,7 +241,7 @@ export function createSimpleErrorMessage(diagnostics, _fileName) {
242
241
  const firstDiagnostic = diagnostics[0];
243
242
  if (!firstDiagnostic)
244
243
  return '';
245
- const message = ts.flattenDiagnosticMessageText(firstDiagnostic.messageText, '\n');
244
+ const message = typescript.flattenDiagnosticMessageText(firstDiagnostic.messageText, '\n');
246
245
  // Extraer solo la primera línea del mensaje para simplicidad
247
246
  const simplifiedMessage = message.split('\n')[0];
248
247
  let location = '';