Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions packages/plugin-dts/src/tsc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ export async function emitDts(
const start = Date.now();
const { configPath, declarationDir, name, dtsExtension, banner, footer } =
options;
const configFileParseResult = loadTsconfig(configPath);
const {
options: rawCompilerOptions,
fileNames,
projectReferences,
} = loadTsconfig(configPath);
} = configFileParseResult;

const compilerOptions = {
...rawCompilerOptions,
Expand All @@ -49,6 +50,9 @@ export async function emitDts(
options: compilerOptions,
projectReferences,
host,
configFileParsingDiagnostics: ts.getConfigFileParsingDiagnostics(
configFileParseResult,
),
});

const emitResult = program.emit();
Expand All @@ -60,7 +64,7 @@ export async function emitDts(
const diagnosticMessages: string[] = [];

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

const reportDiagnostic = (diagnostic: ts.Diagnostic) => {
const fileLoc = getFileLoc(diagnostic);
const fileLoc = getFileLoc(diagnostic, configPath);

logger.error(
`${fileLoc} - ${color.red('error')} ${color.gray(`TS${diagnostic.code}:`)}`,
Expand Down
7 changes: 5 additions & 2 deletions packages/plugin-dts/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ export function ensureTempDeclarationDir(cwd: string): string {
return dirPath;
}

export function getFileLoc(diagnostic: ts.Diagnostic): string {
export function getFileLoc(
diagnostic: ts.Diagnostic,
configPath: string,
): string {
if (diagnostic.file) {
const { line, character } = ts.getLineAndCharacterOfPosition(
diagnostic.file,
Expand All @@ -47,7 +50,7 @@ export function getFileLoc(diagnostic: ts.Diagnostic): string {
return `${color.cyan(diagnostic.file.fileName)}:${color.yellow(line + 1)}:${color.yellow(character + 1)}`;
}

return '';
return `${color.cyan(configPath)}`;
}

export const prettyTime = (seconds: number): string => {
Expand Down
Loading