Skip to content

Better Readonly Type Management #6

@helmturner

Description

@helmturner

The meta and bsonSchema instance properties are immutable, as are schemas in general. The types. however, do not correctly reflect the mutability of everything. The desired behavior is as follows:

  • meta and bsonSchema properties are readonly, as are all nested properties
  • attempting to set meta or bsonSchema, or assign to any nested property, should be prevented by TypeScript
  • The parse result types inferred by B.Type should NOT be readonly
  • An object schema built from another object schema's meta.shape property should behave and be typed just like a default instance of the original schema
  • There should be as few readonly or Readonly<> repetitions in the tooltip as is necessary to achieve the above goals

It may be necessary to create Meta and BsonSchema classes to achieve this in a way that is both type-safe and ergonomic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions