Skip to content

Commit 4b556a6

Browse files
committed
update
1 parent f91d70b commit 4b556a6

File tree

1 file changed

+26
-24
lines changed

1 file changed

+26
-24
lines changed

articles/azure-resource-manager/bicep/user-defined-data-types.md

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ ms.date: 01/09/2023
99

1010
Learn how to use user-defined data types in Bicep.
1111

12-
Bicep version 1.2 or newer is required. To install the latest versions, see [Install](./install.md).
12+
[Bicep version 1.2 or newer](./install.md) is required to use this feature.
1313

1414
## Enable the preview feature
1515

16-
To enable this preview, modify your project's [bicepconfig.json file](./bicep-config.md) to include the following JSON:
16+
To enable this preview, modify your project's [bicepconfig.json](./bicep-config.md) file to include the following JSON:
1717

1818
```json
1919
{
@@ -25,36 +25,38 @@ To enable this preview, modify your project's [bicepconfig.json file](./bicep-co
2525

2626
## User-defined data type syntax
2727

28+
You can use the `type` statement to define user-defined data types. In addition, you can also use type expressions in some places to define custom types.
29+
2830
```bicep
2931
Type <userDefinedDataTypeName> = <typeExpression>
3032
```
3133

32-
Valid type expression include:
34+
The valid type expressions include:
3335

34-
- Strings, integers, and booleans are valid data types to be used as type expressions.
36+
- Symbolic references are identifiers that refer to an *ambient* type (like `string` or `int`) or a user-defined type symbol declared in a `type` statement:
3537

3638
```bicep
37-
// a string type with three allowed values.
38-
type myStringLiteral = 'bicep' | 'arm' | 'azure'
39-
40-
// an integer type with one allowed value
41-
type myIntLiteral = 10
39+
// Bicep data type reference
40+
type myStringType = string
4241
43-
// an boolean type with one allowed value
44-
type myBoolLiteral = true
42+
// user-defined type reference
43+
type myOtherStringType = myStringType
4544
```
4645
47-
- Symbolic references of [Bicep data types](./data-types.md) or user-defined data types are valid type expressions.
46+
- Primitive literals, including strings, integers, and booleans, are valid type expressions. For example:
4847
4948
```bicep
50-
// Bicep data type reference
51-
type myStringType = string
49+
// a string type with three allowed values.
50+
type myStringLiteralType = 'bicep' | 'arm' | 'azure'
5251
53-
// user-defined type reference
54-
type myOtherStringType = myStringType
52+
// an integer type with one allowed value
53+
type myIntLiteralType = 10
54+
55+
// an boolean type with one allowed value
56+
type myBoolLiteralType = true
5557
```
5658
57-
- Array types can be declared by suffixing `[]` to any valid type expression.
59+
- Array types can be declared by suffixing `[]` to any valid type expression:
5860
5961
```bicep
6062
// A string type array
@@ -64,7 +66,7 @@ Valid type expression include:
6466
6567
type myIntArrayOfArraysType = int[][]
6668
67-
// A mixed type array with four allowed values
69+
// A mixed-type array with four allowed values
6870
type myMixedTypeArrayType = ('fizz' | 42 | {an: 'object'} | null)[]
6971
```
7072
@@ -90,19 +92,19 @@ Valid type expression include:
9092
9193
**Recursion**
9294
93-
Object types may use direct or indirect recursion so long as at least leg of the path to the recursion point is optional. For example, the myObject definition in the following example is valid because the directly recursive recursiveProp property is optional:
95+
Object types may use direct or indirect recursion so long as at least leg of the path to the recursion point is optional. For example, the `myObjectType` definition in the following example is valid because the directly recursive `recursiveProp` property is optional:
9496
9597
```bicep
96-
type myObject = {
98+
type myObjectType = {
9799
stringProp: string
98-
recursiveProp?: myObject
100+
recursiveProp?: myObjectType
99101
}
100102
```
101103
102-
But the following would not be valid because none of `level1`, `level2`, `level3`, `level4`, or `level5` is optional, there is no JSON object that would be able to fulfill this schema.
104+
But the following would not be valid because none of `level1`, `level2`, `level3`, `level4`, or `level5` is optional.
103105
104106
```bicep
105-
type invalidRecursiveObject = {
107+
type invalidRecursiveObjectType = {
106108
level1: {
107109
level2: {
108110
level3: {
@@ -215,4 +217,4 @@ resource storageAccount 'Microsoft.Storage/storageAccounts@2022-09-01' = {
215217

216218
## Next steps
217219

218-
- For a list of the Bicep date types, see [Data types](./data-types.md).
220+
- For a list of the Bicep date types, see [Data types](./data-types.md).

0 commit comments

Comments
 (0)