{"record":{"id":"1340b88261833172","repo":"swc-project/swc","slug":"illegal-conversion-cannot-convert-to-tsliter","errorCode":null,"errorMessage":"illegal conversion: Cannot convert {:?} to TSLiteralTypeLiteral","messagePattern":"illegal conversion: Cannot convert (.+?) to TSLiteralTypeLiteral","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/swc_estree_compat/src/babelify/typescript.rs","lineNumber":812,"sourceCode":"\n    fn babelify(self, ctx: &Context) -> Self::Output {\n        TSLiteralType {\n            base: ctx.base(self.span),\n            literal: self.lit.babelify(ctx),\n        }\n    }\n}\n\nimpl Babelify for TsLit {\n    type Output = TSLiteralTypeLiteral;\n\n    fn babelify(self, ctx: &Context) -> Self::Output {\n        match self {\n            TsLit::Number(n) => TSLiteralTypeLiteral::Numeric(n.babelify(ctx)),\n            TsLit::Str(s) => TSLiteralTypeLiteral::String(s.babelify(ctx)),\n            TsLit::Bool(b) => TSLiteralTypeLiteral::Boolean(b.babelify(ctx)),\n            TsLit::BigInt(i) => TSLiteralTypeLiteral::BigInt(i.babelify(ctx)),\n            _ => panic!(\n                \"illegal conversion: Cannot convert {:?} to TSLiteralTypeLiteral\",\n                &self\n            ),\n        }\n    }\n}\n\n// TODO(dwoznicki): Babel does not appear to have a corresponding template\n// literal TS node.\nimpl Babelify for TsTplLitType {\n    type Output = String;\n\n    fn babelify(self, _ctx: &Context) -> Self::Output {\n        panic!(\"unimplemented\");\n    }\n}\n\nimpl Babelify for TsInterfaceDecl {","sourceCodeStart":794,"sourceCodeEnd":830,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc_estree_compat/src/babelify/typescript.rs#L794-L830","documentation":"A defensive catch-all arm in the babelify conversion for TsLit to TSLiteralTypeLiteral (typescript.rs:812). It fires when the TsLit enum carries a literal variant with no mapped ESTree TSLiteralTypeLiteral kind (anything beyond Number/Str/Bool/BigInt, such as a future or extension variant). In practice it signals that the TsLit input is not one of the four supported literal kinds and the conversion table is incomplete for that variant.","triggerScenarios":"Thrown at crates/swc_estree_compat/src/babelify/typescript.rs:812 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Determine which TsLit variant hit the catch-all (log it) and add a matching arm to TSLiteralTypeLiteral","Reject the input earlier with a descriptive conversion error if the literal kind is genuinely unsupported in ESTree","Guard at the API boundary: only pass TsLit values whose kind is known-supported"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5176682b65416c6b5de6b47379ae1588ea3ecb3f","analyzedAt":"2026-08-17T16:16:52.067Z","contentChangedAt":"2026-08-17T16:16:52.067Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}