{"record":{"id":"0d917c57d6658530","repo":"oxc-project/oxc","slug":"tsenummembername-templatestring-should-have-no","errorCode":null,"errorMessage":"`TSEnumMemberName::TemplateString` should have no substitution and at least one quasi","messagePattern":"`TSEnumMemberName::TemplateString` should have no substitution and at least one quasi","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/oxc_ast/src/ast_impl/ts.rs","lineNumber":22,"sourceCode":"//! [Archived TypeScript spec](https://github.com/microsoft/TypeScript/blob/3c99d50da5a579d9fa92d02664b1b66d4ff55944/doc/spec-ARCHIVED.md)\n\nuse std::fmt;\n\nuse oxc_str::Str;\n\nuse crate::ast::*;\n\nimpl<'a> TSEnumMemberName<'a> {\n    /// Get the name of this enum member.\n    /// # Panics\n    /// Panics if `self` is a `TemplateString` with no quasi.\n    pub fn static_name(&self) -> Str<'a> {\n        match self {\n            Self::Identifier(ident) => ident.name.into(),\n            Self::String(lit) | Self::ComputedString(lit) => lit.value,\n            Self::ComputedTemplateString(template) => template\n                .single_quasi()\n                .expect(\"`TSEnumMemberName::TemplateString` should have no substitution and at least one quasi\"),\n        }\n    }\n}\n\nimpl<'a> TSType<'a> {\n    /// Get the first identifier reference in this type.\n    ///\n    /// For qualified (i.e.  namespaced) types, the left-most identifier is\n    /// returned.\n    pub fn get_identifier_reference(&self) -> Option<&IdentifierReference<'a>> {\n        match self {\n            TSType::TSTypeReference(reference) => reference.type_name.get_identifier_reference(),\n            TSType::TSTypeQuery(query) => match &query.expr_name {\n                TSTypeQueryExprName::IdentifierReference(ident) => Some(ident),\n                _ => None,\n            },\n            _ => None,\n        }","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_ast/src/ast_impl/ts.rs#L4-L40","documentation":"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.","triggerScenarios":"Thrown at crates/oxc_ast/src/ast_impl/ts.rs:22 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}