<commit_before>import * as ts from 'typescript';
import { errorLog } from './logger';

export function checkProgramDiagnosticsErrors(program: ts.Program): void {
	checkDiagnosticsErrors(ts.getPreEmitDiagnostics(program));
	checkDiagnosticsErrors(program.getDeclarationDiagnostics());
}

function checkDiagnosticsErrors(diagnostics: ts.Diagnostic[]): void {
	const errors: string[] = [];
	diagnostics.forEach((diagnostic: ts.Diagnostic) => {
		if (diagnostic.file === undefined || diagnostic.start === undefined) {
			return;
		}

		const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
		const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
		errors.push(`${diagnostic.file.fileName}(${line + 1},${character + 1}): TS${diagnostic.code}: ${message}`);
	});

	if (errors.length === 0) {
		return;
	}

	errorLog(errors.join('\n'));
	throw new Error('Compile with errors');
}<commit_msg>Fixed types to compile with ts 2.6<commit_after>import * as ts from 'typescript';
import { errorLog } from './logger';

export function checkProgramDiagnosticsErrors(program: ts.Program): void {
	checkDiagnosticsErrors(ts.getPreEmitDiagnostics(program));
	checkDiagnosticsErrors(program.getDeclarationDiagnostics());
}

function checkDiagnosticsErrors(diagnostics: ReadonlyArray<ts.Diagnostic>): void {
	const errors: string[] = [];
	diagnostics.forEach((diagnostic: ts.Diagnostic) => {
		if (diagnostic.file === undefined || diagnostic.start === undefined) {
			return;
		}

		const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
		const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
		errors.push(`${diagnostic.file.fileName}(${line + 1},${character + 1}): TS${diagnostic.code}: ${message}`);
	});

	if (errors.length === 0) {
		return;
	}

	errorLog(errors.join('\n'));
	throw new Error('Compile with errors');
}
{'fraction_non_alphanumeric': 0.15595854922279792, 'fraction_numerical': 0.004145077720207254, 'mean_word_length': 6.151851851851852, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5877198', 'n_tokens_mistral': 588, 'n_tokens_neox': 571, 'n_words': 114}