Skip to content

Commit f048e77

Browse files
authored
fix(diagnostics): pretty defaults to true in TS 2.9+ (#372)
- per https://www.typescriptlang.org/tsconfig#pretty - TS 2.9 changed the default to `true`: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-9.html#--pretty-output-by-default - so this is a legacy remnant of older versions of TS - this is why `tsc` by default pretty prints, even when `pretty` is unset - only if it is _explicitly_ set to `false` does it not do that - so change rpt2's diagnostic printing to be `pretty` by default as well - I think this is a pretty _big_ DX improvement, to be honest - I always thought something was up with the error reporting, but saw that there was code for `pretty`, so didn't quite connect the dots until now - that while there was code for it, the default was wrong, and so unless I set `pretty: true`, I wasn't getting easier to read printing - and given that `pretty: true` is the default, that's a redundant / unnecessary option to set in `tsconfig` that I normally wouldn't ever re-set
1 parent 8334c9b commit f048e77

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const typescript: PluginImpl<RPT2Options> = (options) =>
5757
const typecheckFile = (id: string, snapshot: tsTypes.IScriptSnapshot, tcContext: IContext) =>
5858
{
5959
const diagnostics = getDiagnostics(id, snapshot);
60-
printDiagnostics(tcContext, diagnostics, parsedConfig.options.pretty === true);
60+
printDiagnostics(tcContext, diagnostics, parsedConfig.options.pretty !== false);
6161

6262
if (diagnostics.length > 0)
6363
noErrors = false;
@@ -131,7 +131,7 @@ const typescript: PluginImpl<RPT2Options> = (options) =>
131131
// printing compiler option errors
132132
if (pluginOptions.check) {
133133
const diagnostics = convertDiagnostic("options", service.getCompilerOptionsDiagnostics());
134-
printDiagnostics(context, diagnostics, parsedConfig.options.pretty === true);
134+
printDiagnostics(context, diagnostics, parsedConfig.options.pretty !== false);
135135
if (diagnostics.length > 0)
136136
noErrors = false;
137137
}

src/parse-tsconfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export function parseTsConfig(context: IContext, pluginOptions: IOptions)
2020
let loadedConfig: any = {};
2121
let baseDir = pluginOptions.cwd;
2222
let configFileName;
23-
let pretty = false;
23+
let pretty = true;
2424
if (fileName)
2525
{
2626
const text = tsModule.sys.readFile(fileName);

src/print-diagnostics.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { tsModule } from "./tsproxy";
44
import { IContext } from "./context";
55
import { IDiagnostics } from "./tscache";
66

7-
export function printDiagnostics(context: IContext, diagnostics: IDiagnostics[], pretty: boolean): void
7+
export function printDiagnostics(context: IContext, diagnostics: IDiagnostics[], pretty = true): void
88
{
99
diagnostics.forEach((diagnostic) =>
1010
{

0 commit comments

Comments
 (0)