Saltar al contenido
TE732 · Tipos · error

Valor de interpolación CSS con tipo no serializable

Un valor de `@()` viaja como custom property de CSS, y solo `str`, `int` y `float` serializan a una. Un valor tipado `bool`, `View`, map, struct o función se rechaza en compilación — en el render se convertiría en basura o desaparecería. Los valores sin tipo (`Any`) quedan en silencio: este error nunca adivina.

Why this fires

A @(expr) interpolation becomes the value of a CSS custom property on the component's root element. Only str, int, and float serialize into one meaningfully. A bool, a View, a map, a struct, or a function has no CSS spelling — at render time it would either stringify into garbage or be dropped — so the type checker rejects it. TE732 is typeck-owned: it surfaces under zolo check and in the editor; zolo run and zolo build skip the full type check, so there the bad value degrades to initial at render time (dev overlay reports it) instead of failing the build.

fn Card() -> View {
    let visible = true
    <div class="card">
        <style>.card { opacity: @(visible); }</style>
    </div>
}
// error[TE732]: css interpolation expects str, int, or float — found `bool`

Fix it

Compute a CSS-ready value before interpolating:

fn Card() -> View {
    let visible = true
    let opacity = if visible { 1.0 } else { 0.0 }
    <div class="card">
        <style>.card { opacity: @(opacity); }</style>
    </div>
}

For on/off styling, prefer toggling a class in the markup and writing two static rules — that morphs better under the dev server too.

A value the checker cannot type (Any, an unannotated parameter) stays silent by design: this error never guesses.

See also

  • TE733@() glued to adjacent value text.
  • TE737@() with no root element to carry its value.

Véase también

Buscar en Zolo

9 resultados

en