microsoft / microsoft/typespec
Decorators with named parameters?
- Dominant language
- Java
- Stars
- 5.9k
- Forks
- 394
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 104
Description
Currently, it seems that decorators only accept arguments positionally. I'm wondering if it would be feasible/beneficial to support keyword arguments.
```
// 1 - Positional makes it hard to know the expected inputs when there are many options
@petDecorator("Fluffy", 10, "orange", "tuna")
...
// 2 - Makes it a lot easier to know what you are setting, and only set those parameters you care about.
@petDecorator(name: "Fluffy", age: 10, color: "orange", favoriteTreat: "tuna")
...
// 3 - Alternatively, you could just have many small decorators.
@petName("Fluffy") @petAge(10) @petColor("orange") @petFavoriteTreat("tuna")
...
```
Contributor guide
Assessment
This issue has not been assessed yet.