microsoft / typespec

https://typespec.io/
MIT License
4.35k stars 201 forks source link

Library options #1425

Open timotheeguerin opened 1 year ago

timotheeguerin commented 1 year ago

Currently we have a way for emitter to define options but no way for a library to do so.

We kept the design of option configuration open for this purpose but didn't have a real use case. Dpg teams want to be able to define some shared DPG options.

emit:
  - @azure-tools/cadl-python
options: 
  @azure-tools/cadl-dpg
     common-option: "abc"
  @azure-tools/cadl-python:
     python-specfic: "def"
  @azure-tools/cadl-csharp:
     csharp-specfic: "xyz"

And then the dpg library can expose those common options via an helper.

Would need to expand the createLibrary definition to include non emitter options and a way to retrieve the typed options for your library.

Alternative we could have:

markcowl commented 1 year ago
emit:
  - @azure-tools/cadl-python
options: 
  global-options
     common-option: "abc"
  @azure-tools/cadl-python:
     python-specfic: "def"
  @azure-tools/cadl-csharp:
     csharp-specfic: "xyz"
  @azure-tools/cadl-autorest:
     unrelated-option: "xyz"
markcowl commented 1 year ago
emit:
  - @azure-tools/cadl-python
options: 
  @azure-tools/cadl-python:
    common-option: "abc"
     python-specfic: "def"
  @azure-tools/cadl-csharp:
     common-option: "abc"
     csharp-specfic: "xyz"
markcowl commented 1 year ago

Alternatives