Saltar al contenido
TE730 · Tipos · error

Interpolación `@()` fuera de un valor de declaración

`@(expr)` compila a un puente de custom property de CSS (`var(--…)`), que solo existe en valores de declaración — después del `:`, antes del `;`. En un selector, un nombre de propiedad o el preludio de una at-rule no hay `var()` al que compilar, y hacer splice de texto del usuario ahí es un anti-feature deliberado. Mueve la parte dinámica a un valor, o alterna clases estáticas en el markup.

Why this fires

@(expr) compiles to a CSS custom-property bridge: the sheet keeps a constant var(--zc-<hash>-eN) and the computed value rides the component's root element. That machinery only exists in declaration values — after the :, before the ;. In a selector, a property name, or an at-rule prelude there is no var() for the bridge to compile to, so the interpolation is rejected instead of spliced (splicing user text into selectors is exactly the anti-feature the design rules out).

fn Card(cls: str = "card") -> View {
    <div class="card">
        <style>@(cls) { color: red }</style>
    </div>
}
// error[TE730]: `@()` interpolation is only allowed in declaration values

Fix it

Move the dynamic part out of the selector. Select a static class and vary the value instead:

fn Card(accent: str = "red") -> View {
    <div class="card">
        <style>.card { color: @(accent); }</style>
    </div>
}

If you really need a different selector per state, toggle classes in the markup (class={...}) and write one static rule per class.

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