Skip to content

Commit

Permalink
fix(compiler): reduce strictness
Browse files Browse the repository at this point in the history
  • Loading branch information
nivekcode committed Mar 4, 2020
1 parent 680f1f1 commit 19f6480
Showing 1 changed file with 2 additions and 26 deletions.
28 changes: 2 additions & 26 deletions src/lib/compiler/typescript-compiler.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,13 @@
import * as ts from 'typescript';
import { error, info } from '../helpers/log-helper';

const compile = (filePaths: string[], compilerOptions: ts.CompilerOptions): void => {
let program = ts.createProgram(filePaths, compilerOptions);
let emitResult = program.emit();
if (emitResult.emitSkipped) {
error('Error during compilation of Typesript files');
reportDiagnostics(ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics));
} else {
info('Typescript files successfully compiled');
}
};

const reportDiagnostics = (diagnostics: ts.Diagnostic[]): void => {
diagnostics.forEach(diagnostic => {
let message = 'Error';
if (diagnostic.file) {
let { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
message += ` ${diagnostic.file.fileName} (${line + 1},${character + 1})`;
}
message += ': ' + ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
info(message);
});
};

export const compileSources = (filePaths: string[]): void => {
const tsOptions = {
const compilerOptions = {
noEmitOnError: true,
noImplicitAny: true,
declaration: true,
moduleResolution: ts.ModuleResolutionKind.NodeJs,
target: ts.ScriptTarget.ESNext,
module: ts.ModuleKind.ESNext
};
compile(filePaths, tsOptions);
ts.createProgram(filePaths, compilerOptions);
};

0 comments on commit 19f6480

Please sign in to comment.