Azure / Azure/bicep

Add option to create user defined types from static data

Open
#14,715 1 comment 0 reactions 0 assignees View on GitHub
enhancement type system
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.