microsoft / typespec

https://typespec.io/
MIT License
4.13k stars 199 forks source link

Consider making "no emitter was configured" fail if "--warn-as-error" #2325

Closed mikeharder closed 1 year ago

mikeharder commented 1 year ago
$ git diff
--- a/specification/contosowidgetmanager/Contoso.WidgetManager/tspconfig.yaml
+++ b/specification/contosowidgetmanager/Contoso.WidgetManager/tspconfig.yaml
-emit:
-  - "@azure-tools/typespec-autorest"

$ npx tsp compile . --warn-as-error
TypeSpec compiler v0.47.0
Compilation completed successfully.
No emitter was configured, no output was generated. Use `--emit <emitterName>` to pick emitter or specify it in the typespec config.

$ echo $?
0

I would prefer if this returned a non-zero exit code (especially if --warn-as-error), since it's probably not what the user intended, and it's easy to miss this warning. Otherwise, we will update TypeSpecValidation to scrape the "no emitter was configured" error message and fail on it (https://github.com/Azure/azure-rest-api-specs/issues/25041).

https://github.com/microsoft/typespec/blob/f2a5424752a07b12b18d73f2ed24f0dbdc2a99b5/packages/compiler/src/core/cli/actions/compile/compile.ts#L154-L159

markcowl commented 1 year ago

@mikeharder Talking this over with the team, we likely waon't make this a warning, as there are valid scenarios for compiling without a configured emitter. However, it should be easier to add configuration checks, as the config now has a defined schema