Open MaryGao opened 21 hours ago
For context this is not something that is fixed by the symbol refactor as its by design right now that model expression cannot be decoratored. I have a follow up PR to the symbol that makes it an error so its not silently ignored https://github.com/microsoft/typespec/pull/4926. There is no technical limitation to supporting this(we are just not calling checkDecorators
in the checker by design for model expression)
The question here is should we allow model expression to be decorated and if so what is the syntax to do it inline. As we don't really want augment decorator to be the only way to decorate something.
model Foo {
prop: @doc("Doc for this model Exp") {
sub: string;
};
could just have something like that, though it might be ambiguous/need more wrapping for array cases
model Foo {
props: (@doc("Doc for this model Exp") {
sub: string;
})[];
propDict: Record<@doc("Doc for this model Exp") {
sub: string;
}>;
}
there is also the maybe confusion on why you cannot do that
model Foo {
prop: @doc("Doc for this") string;
array: (@doc("Doc for this") string)[];
}
Currently we can add decorators on model declarations but can't decorate on model expressions which would be useful to add decorators for inline/anonymous models.
playground