refactor!: remove any from the public API where it erased type safety#84
Merged
Conversation
sess.Get/Clear take a Source union constraint; on.* helpers take a via.Action func-union constraint; h.Switch/Case become generic over a comparable key (h.Default now needs an explicit type argument). Session's raw Load/Store/Delete KV is unexported — the typed via/sess package is the only access path, reaching it via internal/sessbridge. Adds typed via.BroadcastSignal[T]; the string-keyed signal writes remain as the documented escape hatch for dynamic/client-only keys.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Get/Clearnow take aSourceunion constraint (*via.Ctx | *via.CtxR | *http.Request) — call sites unchanged, wrong types are compile errors instead of a silentfalse.via.Action(func(*Ctx) | func(*Ctx) error);on.Click(42)/on.Click(nil)no longer compile. Bound-method check remains runtime.Switch/Casegeneric overK comparable; mismatched case keys are compile errors.h.Default[K](node)needs an explicit type argument (nothing to infer from).Load/Store/DeleteKV unexported;via/sessis the only access path, wired throughinternal/sessbridge. Public surface is now justRotate.via.BroadcastSignal[T](app, sig, value); string-keyedBroadcastSignals/Patch.Signal(s)/RegisterAppSignalstay as the documented escape hatch for dynamic/client-only signal keys....any,Logger.Logkv pairs, echarts JSONmap[string]any.Breaking
Session.Load/Store/Deleteremoved from public APIh.Defaultrequires explicit type argumenton.*/sess.Get/sess.Clear/h.Switchreject previously-compiling wrong-typed argumentsTesting
go build ./...,go vet ./...,go test ./...all green; gofmt clean