{"record":{"id":"1c6d6a1f9effede0","repo":"swc-project/swc","slug":"illegal-conversion-cannot-convert-to-idorres","errorCode":null,"errorMessage":"illegal conversion: Cannot convert {:?} to IdOrRest","messagePattern":"illegal conversion: Cannot convert (.+?) to IdOrRest","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/swc_estree_compat/src/babelify/typescript.rs","lineNumber":99,"sourceCode":"\n    fn babelify(self, ctx: &Context) -> Self::Output {\n        match self {\n            TsFnParam::Ident(i) => TsFnParamOutput::Id(i.babelify(ctx)),\n            TsFnParam::Array(a) => TsFnParamOutput::Array(a.babelify(ctx)),\n            TsFnParam::Rest(r) => TsFnParamOutput::Rest(r.babelify(ctx)),\n            TsFnParam::Object(o) => TsFnParamOutput::Object(o.babelify(ctx)),\n            #[cfg(swc_ast_unknown)]\n            _ => panic!(\"unable to access unknown nodes\"),\n        }\n    }\n}\n\nimpl From<TsFnParamOutput> for IdOrRest {\n    fn from(o: TsFnParamOutput) -> Self {\n        match o {\n            TsFnParamOutput::Id(i) => IdOrRest::Id(i),\n            TsFnParamOutput::Rest(r) => IdOrRest::Rest(r),\n            _ => panic!(\"illegal conversion: Cannot convert {:?} to IdOrRest\", &o),\n        }\n    }\n}\n\nimpl From<TsFnParamOutput> for Identifier {\n    fn from(o: TsFnParamOutput) -> Self {\n        match o {\n            TsFnParamOutput::Id(i) => i,\n            _ => panic!(\"illegal conversion: Cannot convert {:?} to Identifier\", &o),\n        }\n    }\n}\n\nimpl Babelify for TsTypeParamDecl {\n    type Output = TSTypeParameterDeclaration;\n\n    fn babelify(self, ctx: &Context) -> Self::Output {\n        TSTypeParameterDeclaration {","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc_estree_compat/src/babelify/typescript.rs#L81-L117","documentation":"This panic fires in the `From<TsFnParamOutput> for IdOrRest` conversion when a converted TypeScript function parameter is neither a plain identifier nor a rest element (i.e. it is an Array or Object destructuring pattern). The conversion only supports Id and Rest variants because the target type IdOrRest has no representation for destructuring patterns, so any other variant is rejected as an illegal conversion.","triggerScenarios":"Thrown at crates/swc_estree_compat/src/babelify/typescript.rs:99 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the source TypeScript function parameter is a simple identifier or a rest parameter before converting to IdOrRest","If a destructuring parameter is possible at the call site, match on TsFnParamOutput::Array/Object first and reject or transform them instead of relying on the blanket From impl","Pre-check the TsFnParam variant before calling .into() and surface a descriptive error to the caller instead of panicking"],"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"}