Add (param :as type) annotations to defcomp params across all services and templates

Annotates ~500 defcomp params across 62 files: market (5), blog (7), cart (5),
events (3), federation (4), account (3), orders (2), shared templates (11),
sx docs (14), plus remaining spec fn params (z3, test-framework, adapter-dom,
adapter-async, engine, eval). Total annotations in codebase: 1043.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-11 21:01:02 +00:00
parent 98c1023b81
commit 477ce766ff
62 changed files with 537 additions and 502 deletions

View File

@@ -233,7 +233,7 @@
;; --------------------------------------------------------------------------
(define-async async-render-island
(fn (island (args :as list) (env :as dict) ctx)
(fn ((island :as island) (args :as list) (env :as dict) ctx)
(let ((kwargs (dict))
(children (list)))
(async-parse-kw-args args kwargs children env ctx)

View File

@@ -19,7 +19,7 @@
;; --------------------------------------------------------------------------
(define render-to-dom
(fn (expr (env :as dict) ns)
(fn (expr (env :as dict) (ns :as string))
(set-render-active! true)
(case (type-of expr)
;; nil / boolean false / boolean true → empty fragment
@@ -67,7 +67,7 @@
;; --------------------------------------------------------------------------
(define render-dom-list
(fn (expr (env :as dict) ns)
(fn (expr (env :as dict) (ns :as string))
(let ((head (first expr)))
(cond
;; Symbol head — dispatch on name
@@ -166,7 +166,7 @@
;; --------------------------------------------------------------------------
(define render-dom-element
(fn ((tag :as string) (args :as list) (env :as dict) ns)
(fn ((tag :as string) (args :as list) (env :as dict) (ns :as string))
;; Detect namespace from tag
(let ((new-ns (cond (= tag "svg") SVG_NS
(= tag "math") MATH_NS
@@ -237,7 +237,7 @@
;; --------------------------------------------------------------------------
(define render-dom-component
(fn ((comp :as component) (args :as list) (env :as dict) ns)
(fn ((comp :as component) (args :as list) (env :as dict) (ns :as string))
;; Parse kwargs and children, bind into component env, render body.
(let ((kwargs (dict))
(children (list)))
@@ -284,7 +284,7 @@
;; --------------------------------------------------------------------------
(define render-dom-fragment
(fn ((args :as list) (env :as dict) ns)
(fn ((args :as list) (env :as dict) (ns :as string))
(let ((frag (create-fragment)))
(for-each
(fn (x) (dom-append frag (render-to-dom x env ns)))
@@ -339,7 +339,7 @@
(contains? RENDER_DOM_FORMS name)))
(define dispatch-render-form
(fn ((name :as string) expr (env :as dict) ns)
(fn ((name :as string) expr (env :as dict) (ns :as string))
(cond
;; if — reactive inside islands (re-renders when signal deps change)
(= name "if")
@@ -581,7 +581,7 @@
;; --------------------------------------------------------------------------
(define render-lambda-dom
(fn ((f :as lambda) (args :as list) (env :as dict) ns)
(fn ((f :as lambda) (args :as list) (env :as dict) (ns :as string))
;; Bind lambda params and render body as DOM
(let ((local (env-merge (lambda-closure f) env)))
(for-each-indexed
@@ -605,7 +605,7 @@
;; - Conditional fragments: (when (deref sig) ...) → reactive show/hide
(define render-dom-island
(fn (island (args :as list) (env :as dict) ns)
(fn ((island :as island) (args :as list) (env :as dict) (ns :as string))
;; Parse kwargs and children (same as component)
(let ((kwargs (dict))
(children (list)))
@@ -679,7 +679,7 @@
;; Supports :tag keyword to change wrapper element (default "div").
(define render-dom-lake
(fn ((args :as list) (env :as dict) ns)
(fn ((args :as list) (env :as dict) (ns :as string))
(let ((lake-id nil)
(lake-tag "div")
(children (list)))
@@ -723,7 +723,7 @@
;; Stores the island env and transform on the element for morph retrieval.
(define render-dom-marsh
(fn ((args :as list) (env :as dict) ns)
(fn ((args :as list) (env :as dict) (ns :as string))
(let ((marsh-id nil)
(marsh-tag "div")
(marsh-transform nil)
@@ -781,7 +781,7 @@
;; Marks the attribute name on the element via data-sx-reactive-attrs so
;; the morph algorithm knows not to overwrite it with server content.
(define reactive-attr
(fn (el (attr-name :as string) compute-fn)
(fn (el (attr-name :as string) (compute-fn :as lambda))
;; Mark this attribute as reactively managed
(let ((existing (or (dom-get-attr el "data-sx-reactive-attrs") ""))
(updated (if (empty? existing) attr-name (str existing "," attr-name))))
@@ -802,7 +802,7 @@
;; reactive-fragment — conditionally render a fragment based on a signal
;; Used for (when (deref sig) ...) or (if (deref sig) ...) inside an island.
(define reactive-fragment
(fn (test-fn render-fn (env :as dict) ns)
(fn ((test-fn :as lambda) (render-fn :as lambda) (env :as dict) (ns :as string))
(let ((marker (create-comment "island-fragment"))
(current-nodes (list)))
(effect (fn ()
@@ -824,7 +824,7 @@
;; and reorderings touch the DOM. Without keys, falls back to clear+rerender.
(define render-list-item
(fn (map-fn item (env :as dict) ns)
(fn ((map-fn :as lambda) item (env :as dict) (ns :as string))
(if (lambda? map-fn)
(render-lambda-dom map-fn (list item) env ns)
(render-to-dom (apply map-fn (list item)) env ns))))
@@ -839,7 +839,7 @@
(if dk (str dk) (str "__idx_" index)))))))
(define reactive-list
(fn (map-fn items-sig (env :as dict) ns)
(fn ((map-fn :as lambda) (items-sig :as signal) (env :as dict) (ns :as string))
(let ((container (create-fragment))
(marker (create-comment "island-list"))
(key-map (dict))
@@ -925,7 +925,7 @@
;; Handles: input[text/number/email/...], textarea, select, checkbox, radio
(define bind-input
(fn (el sig)
(fn (el (sig :as signal))
(let ((input-type (lower (or (dom-get-attr el "type") "")))
(is-checkbox (or (= input-type "checkbox")
(= input-type "radio"))))
@@ -960,7 +960,7 @@
;; teardown.
(define render-dom-portal
(fn ((args :as list) (env :as dict) ns)
(fn ((args :as list) (env :as dict) (ns :as string))
(let ((selector (trampoline (eval-expr (first args) env)))
(target (or (dom-query selector)
(dom-ensure-element selector))))
@@ -1000,7 +1000,7 @@
;; Calling (retry) re-renders the body, replacing the fallback.
(define render-dom-error-boundary
(fn ((args :as list) (env :as dict) ns)
(fn ((args :as list) (env :as dict) (ns :as string))
(let ((fallback-expr (first args))
(body-exprs (rest args))
(container (dom-create-element "div" nil))

View File

@@ -151,7 +151,7 @@
;; --------------------------------------------------------------------------
(define process-response-headers
(fn (get-header)
(fn ((get-header :as lambda))
;; Extract all SX response header directives into a dict.
;; get-header is (fn (name) → string or nil).
(dict

View File

@@ -235,7 +235,7 @@
(define call-component
(fn (comp (raw-args :as list) (env :as dict))
(fn ((comp :as component) (raw-args :as list) (env :as dict))
;; Parse keyword args and children from unevaluated arg list
(let ((parsed (parse-keyword-args raw-args env))
(kwargs (first parsed))

View File

@@ -57,7 +57,7 @@
(assert (nil? val) (str "Expected nil but got " (str val)))))
(define assert-type
(fn (expected-type val)
(fn ((expected-type :as string) val)
(let ((actual-type
(if (nil? val) "nil"
(if (boolean? val) "boolean"
@@ -70,17 +70,17 @@
(str "Expected type " expected-type " but got " actual-type)))))
(define assert-length
(fn (expected-len col)
(fn ((expected-len :as number) (col :as list))
(assert (= (len col) expected-len)
(str "Expected length " expected-len " but got " (len col)))))
(define assert-contains
(fn (item col)
(fn (item (col :as list))
(assert (some (fn (x) (equal? x item)) col)
(str "Expected collection to contain " (str item)))))
(define assert-throws
(fn (thunk)
(fn ((thunk :as lambda))
(let ((result (try-call thunk)))
(assert (not (get result "ok"))
"Expected an error to be thrown but none was"))))

View File

@@ -25,7 +25,7 @@
;; --------------------------------------------------------------------------
(define z3-sort
(fn (sx-type)
(fn ((sx-type :as string))
(case sx-type
"number" "Int"
"boolean" "Bool"
@@ -40,7 +40,7 @@
;; --------------------------------------------------------------------------
(define z3-name
(fn (name)
(fn ((name :as string))
(cond
(= name "!=") "neq"
(= name "+") "+"
@@ -74,7 +74,7 @@
;; Operators that get renamed
(define z3-rename-op
(fn (op)
(fn ((op :as string))
(case op
"if" "ite"
"str" "str.++"
@@ -176,7 +176,7 @@
;; --------------------------------------------------------------------------
(define z3-extract-kwargs
(fn (expr)
(fn ((expr :as list))
;; Returns a dict of keyword args from a define-* form
;; (define-primitive "name" :params (...) :returns "type" ...) → {:params ... :returns ...}
(let ((result {})
@@ -184,7 +184,7 @@
(z3-extract-kwargs-loop items result))))
(define z3-extract-kwargs-loop
(fn (items result)
(fn ((items :as list) (result :as dict))
(if (or (empty? items) (< (len items) 2))
result
(if (= (type-of (first items)) "keyword")
@@ -199,12 +199,12 @@
;; --------------------------------------------------------------------------
(define z3-params-to-sorts
(fn (params)
(fn ((params :as list))
;; Convert SX param list to list of (name sort) pairs, skipping &rest/&key
(z3-params-loop params false (list))))
(define z3-params-loop
(fn (params skip-next acc)
(fn ((params :as list) (skip-next :as boolean) (acc :as list))
(if (empty? params)
acc
(let ((p (first params))
@@ -227,7 +227,7 @@
(z3-params-loop rest-p false acc))))))
(define z3-has-rest?
(fn (params)
(fn ((params :as list))
(some (fn (p) (and (= (type-of p) "symbol") (= (symbol-name p) "&rest")))
params)))
@@ -237,7 +237,7 @@
;; --------------------------------------------------------------------------
(define z3-translate-primitive
(fn (expr)
(fn ((expr :as list))
(let ((name (nth expr 1))
(kwargs (z3-extract-kwargs expr))
(params (or (get kwargs "params") (list)))
@@ -282,7 +282,7 @@
;; --------------------------------------------------------------------------
(define z3-translate-io
(fn (expr)
(fn ((expr :as list))
(let ((name (nth expr 1))
(kwargs (z3-extract-kwargs expr))
(doc (or (get kwargs "doc") ""))
@@ -297,7 +297,7 @@
;; --------------------------------------------------------------------------
(define z3-translate-special-form
(fn (expr)
(fn ((expr :as list))
(let ((name (nth expr 1))
(kwargs (z3-extract-kwargs expr))
(doc (or (get kwargs "doc") "")))
@@ -342,7 +342,7 @@
;; --------------------------------------------------------------------------
(define z3-translate-file
(fn (exprs)
(fn ((exprs :as list))
;; Filter to translatable forms and translate each
(let ((translatable
(filter