Reputation: 717
As per the title, I need a way of knowing if a specific file/code has any type errors. I couldn't the right API for this, is there any?
Upvotes: 0
Views: 126
Reputation: 717
It seems that errors can be detected like this:
const {Project} = require ( 'ts-simple-ast' );
const project = new Project ({
tsConfigFilePath: 'tsconfig.json',
addFilesFromTsConfig: false
});
project.addExistingSourceFiles ( 'dst/index.d.ts' );
const hasErrors = !!project.getPreEmitDiagnostics ().length;
Upvotes: 1