1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
import * as path from 'path';
import * as ts from 'typescript4.9';
import { removeAbsolutePaths, COMPILER_OPTIONS } from './typescript-utils';
describe('Typescript 4.9', () => {
it('detects errors', async () => {
const program = ts.createProgram([path.resolve(__dirname, '__fixtures__/typecheck.ts')], COMPILER_OPTIONS);
const diagnostics = ts.getPreEmitDiagnostics(program);
const errors = diagnostics.map(diagnostic => {
const { line, character } = diagnostic.file!.getLineAndCharacterOfPosition(diagnostic.start!);
return `${line}:${character} - ${removeAbsolutePaths(
ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n'),
)}`;
});
expect(Number(ts.versionMajorMinor)).toBe(4.9);
expect(errors.length).toBe(16);
for (const error of errors) {
expect(error).toMatchSnapshot();
}
});
});
|