-
Notifications
You must be signed in to change notification settings - Fork 741
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error not surfaced when attempting to "dot" into type expression #12920
Milestone
Comments
jeskew
added a commit
that referenced
this issue
Jan 26, 2024
Resolves #12920 Resolves #9229 This PR allows elements or properties of types to be used as standalone type expressions. This feature is compatible with both resource-derived types and compile-time imports, as shown in the following example: types.bicep ```bicep @export() type myObject = { quux: int saSku: resource<'Microsoft.Storage/storageAccounts@2022-09-01'>.sku } ``` main.bicep ```bicep import * as types from 'types.bicep' type test = { baz: types.myObject } type test2 = { foo: { bar: test } } type test3 = test2.foo.bar.baz.quux // ^^ compiles to {"$ref": "#/definitions/_1.myObject/properties/quux"} type test4 = test2.foo.bar.baz.saSku.name // ^^ compiles to: // { // "type": "string", // "metadata": { // "__bicep_resource_derived_type!": "Microsoft.Storage/storageAccounts@2022-09-01#properties/sku/properties/name" // } // } ``` Accessing the following element kinds is supported: * Properties may be dereferenced via dot notation * Tuple items may be dereferenced via array index * An object's additional properties type declaration may be dereferenced via a special `.*` syntax * A typed array's element type declaration may be dereferenced via a special `[*]` syntax For example: ```bicep type anObject = { property: int *: string } type strings = string[] type tuple = [int, string] param propertyDeref anObject.property = 10 // type compiles to {"$ref": "#/definitions/anObject/properties/property"} param additionalPropertiesDeref anObject.* = 'foo' // type compiles to {"$ref": "#/definitions/anObject/additionalProperties"} param elementDeref strings[*] = 'bar' // type compiles to {"$ref": "#/definitions/strings/items"} param itemDeref tuple[1] = 'baz' // type compiles to {"$ref": "#/definitions/tuple/prefixItems/1"} ``` ###### Microsoft Reviewers: [Open in CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/Azure/bicep/pull/13047)
asilverman
pushed a commit
that referenced
this issue
Jan 26, 2024
Resolves #12920 Resolves #9229 This PR allows elements or properties of types to be used as standalone type expressions. This feature is compatible with both resource-derived types and compile-time imports, as shown in the following example: types.bicep ```bicep @export() type myObject = { quux: int saSku: resource<'Microsoft.Storage/storageAccounts@2022-09-01'>.sku } ``` main.bicep ```bicep import * as types from 'types.bicep' type test = { baz: types.myObject } type test2 = { foo: { bar: test } } type test3 = test2.foo.bar.baz.quux // ^^ compiles to {"$ref": "#/definitions/_1.myObject/properties/quux"} type test4 = test2.foo.bar.baz.saSku.name // ^^ compiles to: // { // "type": "string", // "metadata": { // "__bicep_resource_derived_type!": "Microsoft.Storage/storageAccounts@2022-09-01#properties/sku/properties/name" // } // } ``` Accessing the following element kinds is supported: * Properties may be dereferenced via dot notation * Tuple items may be dereferenced via array index * An object's additional properties type declaration may be dereferenced via a special `.*` syntax * A typed array's element type declaration may be dereferenced via a special `[*]` syntax For example: ```bicep type anObject = { property: int *: string } type strings = string[] type tuple = [int, string] param propertyDeref anObject.property = 10 // type compiles to {"$ref": "#/definitions/anObject/properties/property"} param additionalPropertiesDeref anObject.* = 'foo' // type compiles to {"$ref": "#/definitions/anObject/additionalProperties"} param elementDeref strings[*] = 'bar' // type compiles to {"$ref": "#/definitions/strings/items"} param itemDeref tuple[1] = 'baz' // type compiles to {"$ref": "#/definitions/tuple/prefixItems/1"} ``` CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/Azure/bicep/pull/13047)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The following has no visible errors:
However if I hover over
![image](https://private-user-images.githubusercontent.com/38542602/294558168-af948f6b-70c7-4581-9331-0d09199a912c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU0MTAyNzMsIm5iZiI6MTcyNTQwOTk3MywicGF0aCI6Ii8zODU0MjYwMi8yOTQ1NTgxNjgtYWY5NDhmNmItNzBjNy00NTgxLTkzMzEtMGQwOTE5OWE5MTJjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTA0VDAwMzI1M1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTFmZjdiYmYzZDYyYjI4NTkzYjNlZjI1NmI1NjU1MjQyNmE4MGIzZDc4NzhmMzkxMzg5ODgwODM2NWY5NjJlYzAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.zulTOKXc5zZVPrm0oawA7met2IYF6b-QtYamGBCUoV4)
test3
, its type is correctly being reported as "error":The same happens when trying to do something which is clearly invalid:
The text was updated successfully, but these errors were encountered: