Skip to content

Unnamed union with named members on the model level #7127

@pawel-kow

Description

@pawel-kow

Clear and concise description of the problem

Problem as stated in #7124

Scenario: model foo has a property bar and one of 2 properties baz and fox.

Potential modelling (or any equivalent that would allow anonymous reference to baz_or_fox where the union properties are named but are directly placed in foo):

model foo {
  bar: uint32;
  ...baz_or_fox;
}

union baz_or_fox {
  baz: uint32;
  fox: uint32;
} 

Currently it throws "Cannot spread properties of non-model type.".

Checklist

  • Follow our Code of Conduct
  • Read the docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    compiler:coreIssues for @typespec/compilerdesign:neededA design request has been raised that needs a proposaltriaged:core

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions