Currently, I am experimenting with the typescript module to programmatically detect typescript errors. Below is a simplified version of what I have been working on:
var ts=require('typescript')
var file_content=`
interface Message{
a:string
b:number
}
var a:Message={a:'hello'}
`
var options={
compilerOptions:{
module:'ES2015',
target:'ES2015',
inlineSourceMap:true
},
reportDiagnostics: true
}
const typescript_output = ts.transpileModule(file_content,options)
console.log(typescript_output.diagnostics)
The issue here is that when I execute the code using node, it consistently displays an empty array for the diagnostics, despite having a typescript error in the content stored in the file_content variable.
I would like to know: What is the correct approach to utilize the typescript module API to retrieve typescript errors?