Add option to create user defined types from static data
- 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.**
Would be nice to have the option to add types from static data in bicep.
Main benefit is that you get intelisence on calling suggestedRoleId() that is dynamically updated.
```bicep
// does not scale
@export()
type RoleName =
| 'Contributor'
| 'Owner'
| 'Reader'
| 'Private DNS Zone Contributor'
| 'Network Contributor'
| 'Log Analytics Reader'
| 'Log Analytics Contributor'
@export()
func lookupRoleId(name RoleName) string => loadJsonContent('roles.json')[?name] ?? null
```
**Describe the solution you'd like**
```bicep
// do scale
var roles = loadJsonContent('roles.json')
@export()
type SuggestedRoleName = items(roles)
@export()
func suggestedRoleId(name SuggestedRoleName) string => roles[name]
```
Contributor guide
Research direction
The issue names no implementation files, entry points, or tests. Start by locating the type-system and IntelliSense handling for exported types and static data, then determine how the proposed items(roles) form should be represented. Done means supporting the illustrated syntax and providing updated suggestions for suggestedRoleId calls.
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