Skip to content

luci-base: form: type section() and option() by the class passed - #9116

Open
virzak wants to merge 1 commit into
openwrt:masterfrom
virzak:luci-base-jsdoc-generics
Open

virzak wants to merge 1 commit into
openwrt:masterfrom
virzak:luci-base-jsdoc-generics

Conversation

@virzak

@virzak virzak commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Pull request details

Description

Follow-up to #9100. section(), option() and taboption() take a class and return an instance of it, but their JSDoc types the argument as an instance of the base class and the result as the base class. This documents the argument as {function(new:T, ...*)} (Closure syntax, which jsdoc.conf.json already enables) and the result as {T}, via @template T.

Generated TypeScript declarations then become option<T>(cbiClass: new (...args: any[]) => T, ...args: any[]): T, so a view gets back the class it passed (form.Value, form.ListValue, ...) instead of AbstractValue. This is the remaining JSDoc gap for #9101: with it, the status-light settings page type-checks in strict mode against declarations generated from master with no local corrections.

jsdoc parses and renders without errors (taboption(tabName, cbiClass, ...args) -> {T}), and eslint reports nothing new for form.js. The prose still names AbstractSection and AbstractValue as the required base classes.

Maintainer (preferred)

@systemcrash


Tested on

Documentation only; no code changes.

@openwrt-ai openwrt-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 new commit.


Generated by Claude Code

Comment thread modules/luci-base/htdocs/luci-static/resources/form.js
Document the class argument as a constructor of T and the result as T,
so tools reading the JSDoc see section(), option() and taboption()
return an instance of the class passed in, not of the base class. Type
SectionValue's subsection_class as a constructor too.

Signed-off-by: Victor Irzak <victor@irzak.com>
@virzak
virzak force-pushed the luci-base-jsdoc-generics branch from 2cc3c03 to 692cd5c Compare October 8, 2026 08:17

@openwrt-ai openwrt-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 new commit; no new issues found.


Generated by Claude Code

This branch has not been deployed

No deployments
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.

2 participants