Repository navigation
Releases
v0.12.0
Upgrading
- A payload can no longer hold a
bigint, becauseJSON.stringifythrows on one (#106). Keep an
integer in the safe range ofnumberasnumber, and one outside it as a decimal string.
Large integers shows the
pattern.
What's Changed
💥 Breaking
Full Changelog: v0.11.0...v0.12.0
v0.11.0
This release reworks the companion API. Code written for 0.10 needs the changes below.
Upgrading
-
Import
Enum,Trait,TagandOtherwisefromvalof.valof/experimentalis removed (#98). -
End every companion chain with
.build(), forVal,EnumandTrait(#86):const User = Val.companion<User>().build();
-
Replace
Val.sealer<User>()withVal.companion<User>(), andUser(payload)with
User.seal(payload)(#82). A companion is not callable. ReplaceEnum.sealerthe same way. -
Pass
implandimplTraita function that returns the members (#92). The function receives
seal,patchandcreatewhenimplCreateregistered one. A member that calls them needs no
return-type annotation:// before .impl({ renamed: (u, name: string): User => User.patch(u, { name }) }) // after .impl(({ patch }) => ({ renamed: (u, name: string) => patch(u, { name }) }))
-
Replace
.fixed<"id">()with a type argument:Val.companion<User, [Unpatchable<"id">]>()(#83). -
Replace
pipe(u, User.greet())withpipe(u, User.greet), where the member's only parameter is
the value.User.greet()is now a type error (#97). -
Replace
Shape.__valof_tagwithShape[Tag](#90). -
Remove
detached-implfrom your valof-lint config (#86).
Enums
Write each variant's steps in the chain after the variant's name, as .Click.implSeal, and declare
a renamed tag with .tag("kind") (#87). implVariant and the companion("kind") argument are
removed:
// before
Enum.companion<Event>("kind")
.implSeal(checkId)
.implVariant("Click", (variant) => variant.implSeal(checkClick).impl({ moved }))
.build();
// after
Enum.companion<Event>()
.tag("kind")
.Click.implSeal(checkClick)
.Click.impl(() => ({ moved }))
.implSeal(checkId)
.build();Warning
An implSeal on the enum, not on a variant, now runs only in Event.seal.
Event.Click.seal, Event.Click.create and Event.Click.patch skip it. Where a check must run
on every variant, move it into each variant's implSeal.
Replace Shape.Circle({ r: 2 }) with Shape.Circle.create({ r: 2 }). A variant's seal expects
the payload including the tag: Shape.Circle.seal({ _tag: "Circle", r: 2 }).
What's Changed
💥 Breaking
- feat!: drop
.sealer, make.sealthe only way in, and.companionoffers default.sealby @jo16oh in #82 - feat!: replace
.fixedwithUnpatchable, and addPrivateSeal, as companion type arguments by @jo16oh in #83 - feat!: close every companion chain with
.build()by @jo16oh in #86 - feat!: rebuild the Enum API as one chain by @jo16oh in #87
- feat!: turn the
__valof_keys into symbols by @jo16oh in #90 - feat!: take the members of impl and implTrait through a function by @jo16oh in #92
- feat!: drop the value-last form from a member taking only the value by @jo16oh in #97
- feat!: drop valof/experimental, and export Enum and Trait from the root by @jo16oh in #98
✨ Features
- feat: add
_tomatchfor the variants without a handler of their own by @jo16oh in #80 - feat: allow any variant name and a
thenmember by @jo16oh in #91 - feat: add implAssoc for members that do not take the value by @jo16oh in #95
🔧 Fixes
- fix: let a consumer emit declarations for an exported companion by @jo16oh in #88
- fix: throw in development on a member hiding a default or a rest parameter by @jo16oh in #102
⚡ Performance
- perf: share the builder steps between Val and Enum by @jo16oh in #93
- perf: wrap what a step's function receives in NoInfer by @jo16oh in #94
📝 Docs
- docs: state the TypeScript requirement in the README, and rewrite the enums chapter by @jo16oh in #96
- docs: merge the README examples into one by @jo16oh in #99
- docs: fix factual errors, and proofread the book and the hovers by @jo16oh in #100
- docs: restructure the book by @jo16oh in #101
Full Changelog: v0.10.0...v0.11.0
v0.10.0
v0.9.1
What's Changed
🔧 Fixes
- fix: reserve the step names, not every name starting with
implby @jo16oh in #72 - fix: reject non-objects for an empty payload by @jo16oh in #71
- fix: reject a trait member's name in an enum's
implby @jo16oh in #73 - fix: include a trait's fields in a Val's payload type by @jo16oh in #74
⚡ Performance
Full Changelog: v0.9.0...v0.9.1
v0.9.0
Upgrading from 0.8
implSeal now rejects a seal whose return type includes a PromiseLike. Do the async work first,
and pass its result to the seal.
What's Changed
💥 Breaking
✨ Features
- feat: reject another variant's fields in the enum's seal, and add
[Tag]by @jo16oh in #63 - feat: add
.implCreate.nosealfor bypassing the seal increateby @jo16oh in #65
🔧 Fixes
- fix(lint): stop reporting implEquals in detached-impl by @jo16oh in #59
- fix(lint): skip reserved names in unused-member by @jo16oh in #60
- fix: reject trait members that overwrite a name the companion holds by @jo16oh in #62
📝 Docs
- docs: describe valof as a library for branded, immutable domain types by @jo16oh in #57
- docs: describe
.implCreate.nosealin custom constructors by @jo16oh in #66
Full Changelog: v0.8.2...v0.9.0
v0.8.2
v0.8.1
v0.8.0
What's Changed
💥 Breaking
- fix!: close three patch holes that produced incomplete values by @jo16oh in #32
- feat!: remove update by @jo16oh in #33
- feat!: replace custom equality with named equals by @jo16oh in #36
- feat: Enum by @jo16oh in #41
✨ Features
- feat: publish Trait from valof/experimental by @jo16oh in #27
- feat: add nocopy sealing by @jo16oh in #37
- feat: let a Val reference itself with Rec by @jo16oh in #42
🔧 Fixes
📝 Docs
🧹 Everything else
- chore: introduce mise by @jo16oh in #30
- test: write payloads plain, without readonly by @jo16oh in #34
- chore: check bundle-size claims by release scope by @jo16oh in #38
- test: typecheck README examples by @jo16oh in #39
- chore: check release claims before push by @jo16oh in #40
Full Changelog: v0.7.0...v0.8.0