Add a shorthand syntax for declaring object properties from existing symbols
- Dominant language
- Bicep
- Stars
- 3.6k
- Forks
- 830
- Avg merge
- 1d 21m
- Merged PRs (30d)
- 79
Description
**Is your feature request related to a problem? Please describe.**
When I want to add a `var` or `param` to an object literal using the symbol's name as the property name, I need to type the symbol name twice:
```bicep
param location string = resourceGroup().location
var obj = {
location: location
}
```
This is inefficient, and can be especially annoying when writing a orchestration template that exposes the parameters of nested modules using the same names:
```bicep
param storageAccountName string
param storageAccountLocation string
module sa 'storageAccount.bicep' = {
name: 'sa'
params: {
storageAccountName: storageAccountName
storageAccountLocation: storageAccountLocation
}
}
```
**Describe the solution you'd like**
Bicep could adopt the shorthand property declaration syntax from ES6/TS:
```bicep
param storageAccountName string
param storageAccountLocation string
module sa 'storageAccount.bicep' = {
name: 'sa'
params: { storageAccountName, storageAccountLocation }
}
```
Contributor guide
Research direction
Start by reviewing the object-literal and module-parameter syntax shown in the issue, then trace how existing symbols become object properties. Done means supporting the proposed shorthand while preserving the existing explicit property form and validating it for both object literals and module params.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100