Skip to content

Commit

Permalink
feat: add fallback for unpluginContext.warn
Browse files Browse the repository at this point in the history
In the warnDiagnostic function, a fallback for unpluginContext.warn
has been added. If unpluginContext.warn is not available, consola.warn
will be used instead. This change ensures that warnings are always
displayed, even if unpluginContext.warn is not defined.
  • Loading branch information
ryoppippi committed Jul 27, 2024
1 parent c71cbe3 commit f72ab61
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/unplugin-typia/src/core/typia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { resolve } from 'pathe';
import { resolveTSConfig } from 'pkg-types';
import { transform as typiaTransform } from 'typia/lib/transform.js';

import { consola } from 'consola';
import type { ResolvedOptions } from './options.ts';
import type { Data, ID, Source, UnContext } from './types.js';
import { wrap } from './types.js';
Expand Down Expand Up @@ -205,9 +206,10 @@ function warnDiagnostic(
unpluginContext: UnContext,
) {
for (const diagnostic of diagnostics) {
unpluginContext.warn(
const warn = unpluginContext?.warn ?? consola.warn;
warn(
transformed.map(e => e.fileName).join(','),
);
unpluginContext.warn(JSON.stringify(diagnostic.messageText));
warn(JSON.stringify(diagnostic.messageText));
}
}

0 comments on commit f72ab61

Please sign in to comment.