microsoft / microsoft/typespec
Apply decorator to a block of models?
- Dominant language
- Java
- Stars
- 5.9k
- Forks
- 394
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 104
Description
Here's an abstraction of a scenario I have encountered:
```
@versioned("1" | "2")
namespace Widget;
model Foo {}
@added("2")
model Bar {
a: A;
b: B;
c: C;
}
@added("2")
model A {}
@added("2")
model B {}
@added("2")
model C {}
```
It would be nice if we had syntax that would support:
```
@versioned("1" | "2")
namespace Widget;
model Foo {}
@added("2") {
model Bar {
a: A;
b: B;
c: C;
}
model A {}
model B {}
model C {}
}
```
It would essentially be shorthand for "apply this decorator to all top-level things in this block". I have used this specifically in the context of the added/removed decorators where it makes the most sense to me. I don't think it generalizes to most decorators, but it potentially could.
Contributor guide
Assessment
This issue has not been assessed yet.