microsoft / typespec

https://typespec.io/
MIT License
4.36k stars 203 forks source link

tspconfig.yml vs tspconfig.yaml #2257

Open mikeharder opened 1 year ago

mikeharder commented 1 year ago

If a spec author accidentally names the config file tspconfig.yml instead of tspconfig.yaml, it can be hard to diagnose. The file is silently ignored, so there is no compiler error, only a warning no emitter was configured which can be easy to miss.

$ npx tsp compile .
TypeSpec compiler v0.46.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.

This happened in a PR, and it took me a while to diagnose:

https://github.com/Azure/azure-rest-api-specs-pr/pull/14001

For now, I will be adding a check in TypeSpecValidation to fail if it detects any file named tspconfig.yml:

https://github.com/Azure/azure-rest-api-specs/issues/25122

Options for @typespec/compiler:

  1. Treats tspconfig.yml as equivalent to tspconfig.yaml
  2. Throw error if it detects file named tspconfig.yml
timotheeguerin commented 1 year ago

Yeah thats a good point, on one side I would say it would be nicer if we had a fixed file name to look for but for either options we have to do the same check to see if tspconfig.yml exists and it also feels a little dumb that we give an error when we can clearly resolve it for the user

allenjzhang commented 9 months ago

We could also simply add an output status line to say tspconfig.yaml found or not found.