Closed wojpawlik closed 3 years ago
@wojpawlik what are you trying to do?
Declaration emit diagnostics are diagnostics that occur when emitting the .d.ts
files.
I'm trying to correctly report all errors, with or without noEmitOnError
, did I get it right?
project.getPreEmitDiagnostics().concat(result.getDiagnostics())
reports errors twice with noEmitOnError: true
,
just result.getDiagnostics()
swallows errors with noEmitOnError: false
.
@wojpawlik I think what would be best is to check for pre-emit diagnostics before emitting, then emit, then check result.getDiagnostics()
.
How can emitting declaration files fail if typechecking reports no issues in project.getPreEmitDiagnostics()
?
@wojpawlik getPreEmitDiagnostics()
does not transform the code and more diagnostics may occur at that time.
See this function in the compiler and how it calls addDiagnostic
: https://github.com/microsoft/TypeScript/blob/38da7c600c83e7b31193a62495239a0fe478cb67/src/compiler/transformers/declarations.ts#L52
Thank you. Last question: why result.getDiagnostic()
does not contain pre-emit diagnostics without noEmitOnError
?
@wojpawlik oh, I did not know it would do that within program.emit()
. You can see the code here: https://github.com/microsoft/TypeScript/blob/f6d425e1e3fb4f52a2935a8d7f7c2133ccbcb63f/src/compiler/program.ts#L3847
@dsherret what code triggers a declaration diagnostic? I wanna test and perhaps refine my diagnostic handling.
@dsherret did I handle diagnostics properly? What are "declaration emit diagnostics", ie. what kinds of errors can they contain? Related: https://github.com/dsherret/ts-morph/issues/384