Pular para o conteúdo
TE732 · Tipos · error

Valor de interpolação CSS com tipo não serializável

Um valor de `@()` viaja como custom property de CSS, e só `str`, `int` e `float` serializam para uma. Valor tipado `bool`, `View`, map, struct ou função é rejeitado em compilação — no render viraria lixo ou sumiria. Valores sem tipo (`Any`) ficam em silêncio: este erro nunca chuta.

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.

Veja também

Buscar no Zolo

9 resultados

en