Skip to content

chore: re-export on.Option instead of leaking internal/spec#99

Merged
joaomdsg merged 1 commit into
mainfrom
chore/on-option-alias
Jun 9, 2026
Merged

chore: re-export on.Option instead of leaking internal/spec#99
joaomdsg merged 1 commit into
mainfrom
chore/on-option-alias

Conversation

@joaomdsg

@joaomdsg joaomdsg commented Jun 9, 2026

Copy link
Copy Markdown
Member

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) carried spec.Option from internal/spec in its exported signature. Downstream modules can't import internal/spec, so they could pass the constructors inline but couldn't:

  • name the type (var o on.Option = on.Debounce("100ms")),
  • build/spread an option slice ([]on.Option{...}),

and godoc rendered an un-importable type name.

Change

Add type Option = spec.Option in package on and 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.

on was 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 Option now resolves to on.Option.)

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
joaomdsg merged commit 5b0b85c into main Jun 9, 2026
4 checks passed
@joaomdsg
joaomdsg deleted the chore/on-option-alias branch June 9, 2026 12:31
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.
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