Skip to content

Commit cfcc89f

Browse files
authored
chore: optimize dts error log (#66)
1 parent 8cd057d commit cfcc89f

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

packages/plugin-dts/src/tsc.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export function emitDts(
5050

5151
for (const diagnostic of allDiagnostics) {
5252
const fileLoc = getFileLoc(diagnostic);
53-
const message = `${fileLoc} error TS${diagnostic.code}: ${ts.flattenDiagnosticMessageText(
53+
const message = `${fileLoc} - ${color.red('error')} ${color.gray(`TS${diagnostic.code}:`)} ${ts.flattenDiagnosticMessageText(
5454
diagnostic.messageText,
5555
host.getNewLine(),
5656
)}`;
@@ -84,7 +84,7 @@ export function emitDts(
8484
const fileLoc = getFileLoc(diagnostic);
8585

8686
logger.error(
87-
`${fileLoc} error TS${diagnostic.code}:`,
87+
`${fileLoc} - ${color.red('error')} ${color.gray(`TS${diagnostic.code}:`)}`,
8888
ts.flattenDiagnosticMessageText(
8989
diagnostic.messageText,
9090
formatHost.getNewLine(),

packages/plugin-dts/src/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import fs, { writeFileSync } from 'node:fs';
22
import path from 'node:path';
3+
import color from 'picocolors';
34
import * as ts from 'typescript';
45

56
export function loadTsconfig(tsconfigPath: string): ts.ParsedCommandLine {
@@ -37,7 +38,7 @@ export function getFileLoc(diagnostic: ts.Diagnostic): string {
3738
diagnostic.file,
3839
diagnostic.start!,
3940
);
40-
return `${diagnostic.file.fileName}:${line + 1}:${character + 1} - `;
41+
return `${color.cyan(diagnostic.file.fileName)}:${color.yellow(line + 1)}:${color.yellow(character + 1)}`;
4142
}
4243

4344
return '';

0 commit comments

Comments
 (0)