microsoft / microsoft/typespec
A way to specify a decorator usage
- Dominant language
- Java
- Stars
- 5.9k
- Forks
- 394
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 104
Description
In #1339 I added an helper to verify that you didn't use the same decorator twice on the same node.
This is however a behavior that most decorator would probably want. If you actually specify it twice you probably made a mistake and should remove one. There is some cases however where you do want to allow multiple like `@extension` in openapi where you add new extensions.
Wondering if we could have a more built-in way to specify that a decorator should only be used once on the same node.
Note: This is just about usage on the same node(syntax) the docorator could very well still be used twice on the same type when using `model is` or `op is`. For example `@route` can be respecified on the `op is` to override but you shouldn't be using 2 `@route` on the same node.
That note is also maybe another thing that should be built in the usage specification:
- multi
- unique per node
- unique per type(don't allow override). Do we really have use case for this.
Contributor guide
Assessment
This issue has not been assessed yet.