Collapse model.Union(None | T) into T
@@ -88,10 +88,18 @@ func annotateObjectProperties(modelType model.Type, schemaType schema.Type) {
}
}
case *model.UnionType:
+ // sometimes optional schema types are represented as unions: None | T
+ // in this case, we want to collapse the union and annotate the underlying type T
+ if len(arg.ElementTypes) == 2 && arg.ElementTypes[0] == model.NoneType {
+ annotateObjectProperties(arg.ElementTypes[1], schemaType)
+ } else if len(arg.ElementTypes) == 2 && arg.ElementTypes[1] == model.NoneType {
+ annotateObjectProperties(arg.ElementTypes[0], schemaType)
+ } else {
// TODO https://github.com/pulumi/pulumi/issues/10993
// We need to handle the case where the schema type is a union type.
}
}
+}
func (b *binder) bindInvokeSignature(args []model.Expression) (model.StaticFunctionSignature, hcl.Diagnostics) {
if len(args) < 1 {
