mirror of
https://github.com/ezolenko/rollup-plugin-typescript2.git
synced 2025-12-08 19:06:16 +00:00
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
This commit is contained in:
parent
8334c9b50f
commit
f048e770be
@ -57,7 +57,7 @@ const typescript: PluginImpl<RPT2Options> = (options) =>
|
||||
const typecheckFile = (id: string, snapshot: tsTypes.IScriptSnapshot, tcContext: IContext) =>
|
||||
{
|
||||
const diagnostics = getDiagnostics(id, snapshot);
|
||||
printDiagnostics(tcContext, diagnostics, parsedConfig.options.pretty === true);
|
||||
printDiagnostics(tcContext, diagnostics, parsedConfig.options.pretty !== false);
|
||||
|
||||
if (diagnostics.length > 0)
|
||||
noErrors = false;
|
||||
@ -131,7 +131,7 @@ const typescript: PluginImpl<RPT2Options> = (options) =>
|
||||
// printing compiler option errors
|
||||
if (pluginOptions.check) {
|
||||
const diagnostics = convertDiagnostic("options", service.getCompilerOptionsDiagnostics());
|
||||
printDiagnostics(context, diagnostics, parsedConfig.options.pretty === true);
|
||||
printDiagnostics(context, diagnostics, parsedConfig.options.pretty !== false);
|
||||
if (diagnostics.length > 0)
|
||||
noErrors = false;
|
||||
}
|
||||
|
||||
@ -20,7 +20,7 @@ export function parseTsConfig(context: IContext, pluginOptions: IOptions)
|
||||
let loadedConfig: any = {};
|
||||
let baseDir = pluginOptions.cwd;
|
||||
let configFileName;
|
||||
let pretty = false;
|
||||
let pretty = true;
|
||||
if (fileName)
|
||||
{
|
||||
const text = tsModule.sys.readFile(fileName);
|
||||
|
||||
@ -4,7 +4,7 @@ import { tsModule } from "./tsproxy";
|
||||
import { IContext } from "./context";
|
||||
import { IDiagnostics } from "./tscache";
|
||||
|
||||
export function printDiagnostics(context: IContext, diagnostics: IDiagnostics[], pretty: boolean): void
|
||||
export function printDiagnostics(context: IContext, diagnostics: IDiagnostics[], pretty = true): void
|
||||
{
|
||||
diagnostics.forEach((diagnostic) =>
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user