Duolith docs

Errors while checking a page

E0174 Behaviour input written or unpacked

Message name writes its input; a behaviour reads its input where it uses it, and never writes it

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 behaviour's input is the one object its caller passes, like props: each value is read where the behaviour uses it, so it stays live, conditions included (decision 0152). Writing the input, or a value inside it at any depth (input.start = 1, input.range.from = day, delete input.start), through the input or any variable that names it (const i = input), would be lost the next time the caller's values change, and would change the caller's own objects. Unpacking it where it is declared, function calendar({ min }), or at the top of the body, let { min } = input, reads each value once, so the behaviour would never see it change; both are refused. Inside a function, derived value or effect, unpacking reads the values each time that code runs, so it is allowed.

How to fix it

Name the input (function calendar(input: { min: string })) and read input.min where it is needed. To change a value, keep it in the behaviour's own state, or take a function to call, such as onChange: (value: string) => void.

In a terminal

duolith explain E0174

Mentioned in