Skip to content

Conversation

@THardy98
Copy link
Contributor

@THardy98 THardy98 commented Oct 22, 2025

What was changed

Changes the RawValue API. Formerly, you could create a RawValue from any given value via the constructor. However, it was not possible to create a RawValue directly with a payload.

This PR changes the API to instead:

  • allow RawValue to be created directly from a payload, via its constructor (changing the constructor signature is the breaking change)
  • all RawValue to still be created with any given value, via a static method fromValue

Why?

Imo, this API makes more sense. If we wanted to keep the old API, but expand it to include a static for fromPayload it would probably look something like this:

  static fromPayload<T = unknown>(payload: Payload): RawValue<T> {
      const instance = Object.create(RawValue.prototype) as RawValue<T>;
      (instance as any)._payload = payload;
      return instance;
  }

which isn't very nice, despite being a basic case.

alternatively, we could expand the type of the value in the constructor to T | Payload and add some type guard checks. Also not very nice, imo.

  1. How was this tested:
    Updated existing tests.

  2. Any docs updates needed?
    Not sure

@THardy98 THardy98 changed the title [BREAKING CHANGE] Improve RawValue API [BREAKING CHANGE] Change RawValue API Oct 22, 2025
@THardy98
Copy link
Contributor Author

THardy98 commented Oct 22, 2025

Not really expecting this to be merged or anything (at least, not without discussion). Mostly want to put this up for awareness. I'm ok with the other options as well, but I do think this is missing functionality.

@THardy98 THardy98 changed the title [BREAKING CHANGE] Change RawValue API [BREAKING CHANGE] Change RawValue API - create RawValue directly from Payload Oct 22, 2025
@THardy98 THardy98 closed this Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant