typescript#DiagnosticCategory TypeScript Examples
The following examples show how to use
typescript#DiagnosticCategory.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.ts From typescript-error-reporter-action with MIT License | 6 votes |
async function main() {
try {
const currentDir = process.cwd()
const configPath = path.resolve(currentDir, 'tsconfig.json')
if (!fs.existsSync(configPath)) {
throw new Error(`could not find tsconfig.json at: ${currentDir}`)
}
const tsVersion = parseTSVersion(currentDir)
const remoteTS = await loadTSModule(tsVersion)
const doctor = Doctor.fromConfigFile(configPath, remoteTS)
const diagnostics = doctor.getSemanticDiagnostics()
if (diagnostics) {
doctor.reporter.reportDiagnostics(diagnostics)
const errors = diagnostics.filter(d => d.category === DiagnosticCategory.Error)
if (errors.length) {
setFailed(`Found ${errors.length} errors!`)
}
}
} catch (e) {
setFailed(e)
}
}