Azure / typespec-azure

About TypeSpec Azure Libraries
https://azure.github.io/typespec-azure/
MIT License
9 stars 29 forks source link

[TCGC] - SourceModel for anonymous models #1132

Open joheredi opened 2 weeks ago

joheredi commented 2 weeks ago

Clear and concise description of the problem

There are scenarios where tracking the source model of anonymous models is beneficial. For instance, in TypeScript code generation, this feature would enable us to map serializer/deserializer types between RLC (Rest Level Client) and Modular. This functionality is crucial for bridging gaps between RLC and Modular types.

Example Consider the following TypeSpec model:

model Foo {
   bar: {
      baz: string;
   }
} 

With the ability to track the source model, we could implement the following TypeScript code:

declare function deserializeFooBar(input: FooRest["bar"]): BarModel;

Here, BarModel is generated from TCGC, but there is no equivalent interface in RLC as it doesn't generate anonymous models.

Checklist

tadelesh commented 2 weeks ago

could you clarify the source meaning? for example, if anonymous model is in parameter, what should the source model be? other cases are model property, return type, etc.