chore: re-export on.Option instead of leaking internal/spec#99
Merged
Conversation
Every handler helper in package on (Click, Input, …) and every option
constructor (Debounce, Throttle, Prevent, Stop, SetSignal) had
`spec.Option` from internal/spec in its exported signature. Downstream
modules cannot import internal/spec, so they could pass the constructors
inline but could not name the type — no `var o on.Option`, no
`[]on.Option{...}` to spread — and godoc rendered an un-importable type.
Add `type Option = spec.Option` in package on and use it across the
public signatures. This mirrors what every other subpackage already does
(mw.HSTSOption, echarts.ChartOption/SeriesOption, vianats.Option): export
the option type, keep the config/trigger struct unexported. Alias keeps
the constructors' returns assignable, so internal wiring is unchanged.
joaomdsg
added a commit
that referenced
this pull request
Jun 9, 2026
Codify the rule behind the on.Option fix (#99): export the functional- option type, keep the config it mutates unexported and in-package, and never reference an unexported or internal/ type in a constructor's signature. Includes the alias re-export guidance for shared option types.
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.
Next subpackage-surface cleanup (follows #97, #98).
Finding
Every handler helper in
on(Click,Input,Submit, …) and every option constructor (Debounce,Throttle,Prevent,Stop,SetSignal) carriedspec.Optionfrominternal/specin its exported signature. Downstream modules can't importinternal/spec, so they could pass the constructors inline but couldn't:var o on.Option = on.Debounce("100ms")),[]on.Option{...}),and godoc rendered an un-importable type name.
Change
Add
type Option = spec.Optionin packageonand use it across the 17 public signatures. Mirrors what every other subpackage already does —mw.HSTSOption,echarts.ChartOption/SeriesOption,vianats.Option: export the option type, keep the config/trigger struct unexported. Being an alias, the constructors' returns stay assignable; internal wiring is unchanged.onwas the only subpackage with this leak — sess/vianats/memevents/backplanetest/plugins surfaces audited clean.Verification
go build,go vet,gofmt -l(clean),go test -race ./...green. (go doc ./on Optionnow resolves toon.Option.)