T01

Error

Types

T01 — A value of the wrong type

A value given to a prop, a state, a field, a parameter or an assignment that is not of the type it is declared to hold.

What the compiler said

error[T01]: `count` is `String`, but `Number` is wanted --> src/App.wf:4:34 | 4 | Button("Reset") { on click { count = "zero" } } | ^^^^^^^^^^^^^^ = help: Convert it: `Number(value)` = docs: https://webfluent.monzeromer.dev/errors/T01

The fix

Broken

wf

page P(path: "/", title: "T", description: "D") { state count: Number = 0 Heading("Counter").h1 Button("Reset") { on click { count = "zero" } } }

Fixed

wf

page P(path: "/", title: "T", description: "D") { state count: Number = 0 Heading("Count {count}").h1 Button("Reset") { on click { count = 0 } } }

Give the state a value of its type, or convert: Number(text), "{n}". If the state really holds one or the other, say so with an enum whose cases carry each (enum Amount { text(value: String), number(value: Number) }), or Json for JSON whose shape is open.

A number a built-in cannot be given is one too: a Carousel(interval:) outside 1 to 2147483647 milliseconds (-5000 used to become a 0 ms autoplay), a Column(span:) that is not a whole number from 1 to 12.

page P(path: "/", title: "T", description: "D") {
    Heading("Grid").h1
    Row { Column(span: 13) { Text("Wide") } }
}
error[T01]: `span` of Column is 13, but a whole number of the 12 columns, from 1 to 12, is wanted
 --> src/App.wf:3:11
  |
3 |     Row { Column(span: 13) { Text("Wide") } }
  |           ^^^^^^
  = help: `span: 6` is half the row
  = docs: https://webfluent.monzeromer.dev/errors/T01

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.