Skip to content

Commit

Permalink
fix: use pretty compiler option for diagnostics
Browse files Browse the repository at this point in the history
BREAKING CHANGE: betterDiagnostics option has been removed
  • Loading branch information
jeremyben committed Jul 26, 2019
1 parent 3288b56 commit 3c8db99
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export function createProgramFromConfig({
* Compile Typescript files and emit diagnostics if any, throws an error if it fails.
* @public
*/
export function emit(program: ts.Program, { basePath, clean, copyOtherToOutDir, betterDiagnostics }: EmitOptions = {}) {
export function emit(program: ts.Program, { basePath, clean, copyOtherToOutDir }: EmitOptions = {}) {
const options = program.getCompilerOptions()

if (clean) cleanTargets(clean, options, basePath)
Expand All @@ -84,7 +84,7 @@ export function emit(program: ts.Program, { basePath, clean, copyOtherToOutDir,

// https://github.com/dsherret/ts-morph/issues/384
const allDiagnostics = ts.getPreEmitDiagnostics(program).concat(diagnostics)
logDiagnostics(allDiagnostics, betterDiagnostics)
logDiagnostics(allDiagnostics, options.pretty as boolean | undefined)

if (!options.noEmit && emitSkipped) {
console.error(red('Compilation failed'))
Expand Down
5 changes: 0 additions & 5 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ export interface CreateProgramFromConfigOptions extends TsConfig {
}

export interface EmitOptions {
/**
* Format diagnostics with colors and context, instead of single lines.
*/
betterDiagnostics?: boolean

/**
* Copy non typescript files and folders to `outDir` path if defined in compiler options.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/log.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import ts from 'typescript'
* Log compiler diagnostics to stderr.
* @internal
*/
export function logDiagnostics(diagnostics: ts.Diagnostic[], better = false) {
export function logDiagnostics(diagnostics: ts.Diagnostic[], pretty = false) {
if (!diagnostics.length) return

const formatHost: ts.FormatDiagnosticsHost = {
Expand All @@ -13,7 +13,7 @@ export function logDiagnostics(diagnostics: ts.Diagnostic[], better = false) {
getNewLine: () => ts.sys.newLine,
}

const message = better
const message = pretty
? ts.formatDiagnosticsWithColorAndContext(diagnostics, formatHost)
: ts.formatDiagnostics(diagnostics, formatHost)

Expand Down

0 comments on commit 3c8db99

Please sign in to comment.