fromdeno / deno2node

Compile your Deno project to run on Node.js.
MIT License
117 stars 3 forks source link

Allow `"noEmitOnError": false` #8

Closed wojpawlik closed 3 years ago

wojpawlik commented 3 years ago

@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

dsherret commented 3 years ago

@wojpawlik what are you trying to do?

Declaration emit diagnostics are diagnostics that occur when emitting the .d.ts files.

wojpawlik commented 3 years ago

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.

dsherret commented 3 years ago

@wojpawlik I think what would be best is to check for pre-emit diagnostics before emitting, then emit, then check result.getDiagnostics().

wojpawlik commented 3 years ago

How can emitting declaration files fail if typechecking reports no issues in project.getPreEmitDiagnostics()?

dsherret commented 3 years ago

@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

wojpawlik commented 3 years ago

Thank you. Last question: why result.getDiagnostic() does not contain pre-emit diagnostics without noEmitOnError?

dsherret commented 3 years ago

@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

wojpawlik commented 3 years ago

@dsherret what code triggers a declaration diagnostic? I wanna test and perhaps refine my diagnostic handling.