Duolith docs

Errors E0300 to E0399

E0340 Wrong type

Message {TypeScript's message} (TSnumber)

Words in italics are filled in when the compiler reports it, such as the element's name or the list of known ones.

Why

A value has a type the place it is used does not accept: a number passed to a string prop, a string where an attribute takes true or false, a word an attribute does not know (type="emial"), a handler that expects something other than what its event gives, or a binding whose state and field disagree. When the page ran it would show the wrong thing, or fail. duolith check, duolith build and duolith dev run TypeScript over the script block and every typed position in the markup (docs/explanation/types.md); the editor shows the same error.

How to fix it

Change the value to the type the place takes, or change the type it is declared with. For a binding, give the state the field's type, such as state<number>(0) for a slider.

In a terminal

duolith explain E0340

Mentioned in