Skip to content

v1 design #25

@chris-pardy

Description

@chris-pardy

There are a number of design mistakes that exist in Type-Shift that should be addressed for V1:

  1. Use of exceptions for errors - This was done because other libraries that don't do this are much harder to interact with. However the design of V1 should have the flow of data between converters be done using success or failure tagged objects.
  2. Lack of symmetry between input and output. The primary advantage to this is the for most converters you simply transform and return the value. However by moving all the data into a single properties object that can be used both for input and output it will enable things like path transforms much cleaner. Additionally new input fields can be added with little to no issue.
  3. Treating missing and undefined as equivalent. While this is generally true in javascript the fact that the in operator and the Object.keys / values / entries methods will treat a present but undefined key differently then a non-present key means that we should support handling that in our converters.
  4. Core types separated from common higher level / coercive / opinionated types - Things like string / number / boolean should be very strict and act as building blocks for other types. Higher level types such as a coercive number type that allows strings that are valid numbers should be build from these low level types. This should also allow the inclusion of opinionated types that we would expect more usage of.
  5. Fixes to optional / required - currently optionality happens at the beginning of a converter and "skips" a converter. This breaks when a converter has a default value which would substitute in a different input value. However to properly fix this in a generic way we need to know that a converter would have produced an empty value if that was allowed. Practically this needs to be done by embedding the idea of optionally deeply within the converters.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions