swc-project/swc · error · Error
Unexpected '}' in declaration value
Error message
Unexpected '}' in declaration value
What it means
Fired by the declaration-value validator: a preserved '}' token appears in a declaration value without a matching '{' block. Unbalanced closing braces make the declaration value invalid per CSS Syntax, so an error is recorded.
Source
Thrown at crates/swc_css_parser/src/parser/util.rs:386
&mut self,
component_value: &ComponentValue,
) -> PResult<()> {
let ComponentValue::PreservedToken(preserved_token) = component_value else {
return Ok(());
};
let kind = match preserved_token.token {
Token::BadString { .. } => ErrorKind::Unexpected("bad string in declaration value"),
Token::BadUrl { .. } => ErrorKind::Unexpected("bad url in declaration value"),
Token::RParen => ErrorKind::Unexpected("')' in declaration value"),
Token::RBracket => ErrorKind::Unexpected("']' in declaration value"),
Token::RBrace => ErrorKind::Unexpected("'}' in declaration value"),
Token::Semi => ErrorKind::Unexpected("';' in declaration value"),
Token::Delim { value: '!' } => ErrorKind::Unexpected("'!' in declaration value"),
_ => return Ok(()),
};
Err(Error::new(preserved_token.span, kind))
}
}
pub(super) struct WithCtx<'w, I: 'w + ParserInput> {
inner: &'w mut Parser<I>,
orig_ctx: Ctx,
}
impl<I: ParserInput> Deref for WithCtx<'_, I> {
type Target = Parser<I>;
fn deref(&self) -> &Parser<I> {
self.inner
}
}
impl<I: ParserInput> DerefMut for WithCtx<'_, I> {
fn deref_mut(&mut self) -> &mut Parser<I> {
self.innerView on GitHub (pinned to 5176682b65)
Solutions
- Remove the stray '}' or add the matching '{' block
- Rebalance braces inside the declaration value
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/swc_css_parser/src/parser/util.rs:386 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of swc-project/swc@5176682b65 (2026-08-17).
Data as JSON: /api/errors/d481428113c13ffa.
Report an issue: GitHub.