Skip to content

Commit

Permalink
chore: optimize dts error log
Browse files Browse the repository at this point in the history
  • Loading branch information
9aoy committed Aug 6, 2024
1 parent 8cd057d commit 0fd2f14
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/plugin-dts/src/tsc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function emitDts(

for (const diagnostic of allDiagnostics) {
const fileLoc = getFileLoc(diagnostic);
const message = `${fileLoc} error TS${diagnostic.code}: ${ts.flattenDiagnosticMessageText(
const message = `${fileLoc} - ${color.red('error')} ${color.gray(`TS${diagnostic.code}:`)} ${ts.flattenDiagnosticMessageText(
diagnostic.messageText,
host.getNewLine(),
)}`;
Expand Down Expand Up @@ -84,7 +84,7 @@ export function emitDts(
const fileLoc = getFileLoc(diagnostic);

logger.error(
`${fileLoc} error TS${diagnostic.code}:`,
`${fileLoc} - ${color.red('error')} ${color.gray(`TS${diagnostic.code}:`)}`,
ts.flattenDiagnosticMessageText(
diagnostic.messageText,
formatHost.getNewLine(),
Expand Down
3 changes: 2 additions & 1 deletion packages/plugin-dts/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs, { writeFileSync } from 'node:fs';
import path from 'node:path';
import color from 'picocolors';
import * as ts from 'typescript';

export function loadTsconfig(tsconfigPath: string): ts.ParsedCommandLine {
Expand Down Expand Up @@ -37,7 +38,7 @@ export function getFileLoc(diagnostic: ts.Diagnostic): string {
diagnostic.file,
diagnostic.start!,
);
return `${diagnostic.file.fileName}:${line + 1}:${character + 1} - `;
return `${color.cyan(diagnostic.file.fileName)}:${color.yellow(line + 1)}:${color.yellow(character + 1)}`;
}

return '';
Expand Down

0 comments on commit 0fd2f14

Please sign in to comment.