unyt-org / datex-core-js-legacy

DATEX Core Library for JavaScript (legacy), fully implemented in TypeScript, used by the UIX Framework
https://unyt.org
3 stars 0 forks source link

Allow assigning untyped objects to struct properties #103

Open benStre opened 6 months ago

benStre commented 6 months ago

Currently, nested structs can be created with normal objects, e.g.

const example = MyStruct({
  name: 1,
  address: {
    street: "xy"
  }
})

But when assigning a new object to a property, an error occurs:

example.address = {street: "z"}; // Error: address must be of type <MyAddress>

It should be possible to assign objects without explicitly converting them to the matching type beforehand.