oxc-project/oxc · error
`TSEnumMemberName::TemplateString` should have no substituti
Error message
`TSEnumMemberName::TemplateString` should have no substitution and at least one quasi
What it means
Panic in TSEnumMemberName::static_name when the member is a ComputedTemplateString: it takes the template's first quasi's cooked value, but the doc contract requires the template to have no substitutions (expressions) and at least one quasi. A template with expressions or zero quisis breaks that assumption and the expect fires.
Source
Thrown at crates/oxc_ast/src/ast_impl/ts.rs:22
//! [Archived TypeScript spec](https://github.com/microsoft/TypeScript/blob/3c99d50da5a579d9fa92d02664b1b66d4ff55944/doc/spec-ARCHIVED.md)
use std::fmt;
use oxc_str::Str;
use crate::ast::*;
impl<'a> TSEnumMemberName<'a> {
/// Get the name of this enum member.
/// # Panics
/// Panics if `self` is a `TemplateString` with no quasi.
pub fn static_name(&self) -> Str<'a> {
match self {
Self::Identifier(ident) => ident.name.into(),
Self::String(lit) | Self::ComputedString(lit) => lit.value,
Self::ComputedTemplateString(template) => template
.single_quasi()
.expect("`TSEnumMemberName::TemplateString` should have no substitution and at least one quasi"),
}
}
}
impl<'a> TSType<'a> {
/// Get the first identifier reference in this type.
///
/// For qualified (i.e. namespaced) types, the left-most identifier is
/// returned.
pub fn get_identifier_reference(&self) -> Option<&IdentifierReference<'a>> {
match self {
TSType::TSTypeReference(reference) => reference.type_name.get_identifier_reference(),
TSType::TSTypeQuery(query) => match &query.expr_name {
TSTypeQueryExprName::IdentifierReference(ident) => Some(ident),
_ => None,
},
_ => None,
}View on GitHub (pinned to e1e7af627c)
Solutions
- Match on the TSEnumMemberName variant and handle ComputedTemplateString separately before calling static_name
- Check template.expressions.is_empty() && !template.quasis.is_empty() first
- Return an Option/Result from static_name for non-static names instead of panicking
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at crates/oxc_ast/src/ast_impl/ts.rs:22 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/0d917c57d6658530.
Report an issue: GitHub.