T23
Error
Types
T23 — Any written as a type
7.0 took Any out of the language: a value of a type nothing checks agreed with every other, so a mistake passed it by. Every value has a type the program can name — write it, or Json for JSON whose shape is open, which is matched or decoded before it is read.
What the compiler said
error[T23]: `picked` is written `Any`, which 7.0 took out of the language: every value has a type the program can name --> src/App.wf:4:5 | 4 | state picked: Any = null | ^^^^^^^^^^^^^^^^^^^^^^^^ = help: Write the type it holds, or `Json` for JSON whose shape is open = docs: https://webfluent.monzeromer.dev/errors/T23
Your editor offers this fix: Write Json. wf fix --code T23 applies it to every place it fits.
The fix
Broken
type User { name: String }
store People {
state picked: Any = null
action pick(u: User) { picked = u }
}
page P(path: "/", title: "People", description: "D") {
use People
Heading("People").h1
Button("Ada") { on click { People.pick(User(name: "Ada")) } }
Text(if People.picked == null { "Nobody yet" } else { "Picked" })
}
Fixed
type User { name: String }
store People {
state picked: User? = null
action pick(u: User) { picked = u }
}
page P(path: "/", title: "People", description: "D") {
use People
Heading("People").h1
Button("Ada") { on click { People.pick(User(name: "Ada")) } }
Text(if People.picked == null { "Nobody yet" } else { "Picked" })
}
write the type the value holds. When it is JSON whose shape is
open — what a library or a server hands over and nothing says more of — write
Json, and match it or decode it where it is read. The editor's quick fix,
wf fix --code T23 and wf migrate write Json; a type the program names
is better where you know it.
Each example is a whole program: it is all of src/App.wf in a project with no other .wf file (trying an example).
Why this rule exists
Error.
Any agreed with every type in both directions, so a value of it passed
every check — a misspelt field, a number where text was wanted — and the
page found out. 7.0 has no such type: every value has one the program can
name, written where another declaration or file sees it and inferred where
only the body does.
lints cannot lower it: it would ship a broken page.