{"record":{"id":"ec5b68f317986bff","repo":"sinelaw/fresh","slug":"semantic-errors","errorCode":null,"errorMessage":"Semantic errors: {}","messagePattern":"Semantic errors: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/fresh-parser-js/src/lib.rs","lineNumber":37,"sourceCode":"pub fn transpile_typescript(source: &str, filename: &str) -> Result<String> {\n    let allocator = Allocator::default();\n    let source_type = SourceType::from_path(filename).unwrap_or_default();\n\n    // Parse\n    let parser_ret = Parser::new(&allocator, source, source_type).parse();\n    if !parser_ret.errors.is_empty() {\n        let errors: Vec<String> = parser_ret.errors.iter().map(|e| e.to_string()).collect();\n        return Err(anyhow!(\"TypeScript parse errors: {}\", errors.join(\"; \")));\n    }\n\n    let mut program = parser_ret.program;\n\n    // Semantic analysis (required for transformer)\n    let semantic_ret = SemanticBuilder::new().build(&program);\n\n    if !semantic_ret.errors.is_empty() {\n        let errors: Vec<String> = semantic_ret.errors.iter().map(|e| e.to_string()).collect();\n        return Err(anyhow!(\"Semantic errors: {}\", errors.join(\"; \")));\n    }\n\n    // Get scoping info for transformer\n    let scoping = semantic_ret.semantic.into_scoping();\n\n    // Transform (strip TypeScript types)\n    let transform_options = TransformOptions::default();\n    let transformer_ret = Transformer::new(&allocator, Path::new(filename), &transform_options)\n        .build_with_scoping(scoping, &mut program);\n\n    if !transformer_ret.errors.is_empty() {\n        let errors: Vec<String> = transformer_ret\n            .errors\n            .iter()\n            .map(|e| e.to_string())\n            .collect();\n        return Err(anyhow!(\"Transform errors: {}\", errors.join(\"; \")));\n    }","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/sinelaw/fresh/blob/67894ca5463dbd7a89bb31add4627c27d6b79d83/crates/fresh-parser-js/src/lib.rs#L19-L55","documentation":"After parsing succeeds, `transpile_typescript` runs oxc's semantic analysis; any semantic-level errors reported by SemanticBuilder abort the transpile with this message. The source parsed but failed symbol/scoping analysis needed by the transformer.","triggerScenarios":"Calling `transpile_typescript` on source that parses but produces semantic errors — rare, typically constructs the analyzer rejects (e.g. `super` outside a class, invalid binding forms).","commonSituations":"Hand-edited plugin sources with structurally odd code; generated code fed to the transpiler; oxc version differences flagging constructs previously tolerated.","solutions":["Fix each reported semantic error in the source (message lists them joined by '; ').","Refactor the offending construct (e.g. move `super` usage into a class method).","If it looks like a false positive, check the oxc version in Cargo.lock and update/downgrade accordingly."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if let Err(e) = transpile_typescript(src, \"plugin.ts\") {\n    if e.to_string().starts_with(\"Semantic errors\") { log::error!(\"semantic analysis failed: {e}\"); }\n}","preventionTips":["Keep plugin TypeScript to standard, well-formed constructs.","Pin/update oxc versions deliberately and re-run plugin build tests on bumps.","Include a transpile smoke test for every shipped plugin."],"tags":["typescript","semantic-analysis","parser","plugins"],"backgroundTag":"schema-validation-failed","analyzedSha":"67894ca5463dbd7a89bb31add4627c27d6b79d83","analyzedAt":"2026-09-13T15:04:03.701Z","contentChangedAt":"2026-09-13T15:04:03.701Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}