T17

Error

Types

T17 — An async result used before it is awaited

An action that awaits hands back a promise; read as its result without await it is not one. await is written in an action, a handler, a timer or a hook — not in a derived value or an effect, which run at once — and .pending is for an action that awaits.

What the compiler said

error[T17]: `save` awaits nothing, so `.pending` is always false --> src/App.wf:5:30 | 5 | Button("Save", disabled: save.pending) { on click { save() } } | ^^^^ = help: `.pending` is true while a call of an async action runs; an action that awaits nothing finishes before the page repaints = docs: https://webfluent.monzeromer.dev/errors/T17

The fix

Broken

wf

page P(path: "/", title: "T", description: "D") { state saved = false action save() { saved = true } Heading("Save").h1 Button("Save", disabled: save.pending) { on click { save() } } }

Fixed

wf

page P(path: "/", title: "T", description: "D") { state saved = false action save() { saved = true } Heading("Save").h1 Button("Save", disabled: saved) { on click { save() } } }

.pending is for an action that awaits — drop it here. An async action's result is read with await inside an action or a handler; a value that arrives over the network is a resource, which derived values and elements can read.

Each example is a whole program: it is all of src/App.wf in a project with no other .wf file (trying an example).

lints cannot lower it: it would ship a broken page.