{"record":{"id":"26e411992a5dcffe","repo":"sinelaw/fresh","slug":"transform-errors","errorCode":null,"errorMessage":"Transform errors: {}","messagePattern":"Transform errors: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/fresh-parser-js/src/lib.rs","lineNumber":54,"sourceCode":"        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    }\n\n    // Generate JavaScript\n    let codegen_ret = Codegen::new().build(&program);\n\n    Ok(codegen_ret.code)\n}\n\n/// Emit a TypeScript declaration file (`.d.ts`) from TypeScript source.\n///\n/// Uses oxc's isolated-declarations transformer — no full type checker is\n/// required, but the source must follow TypeScript's\n/// [isolated declarations](https://www.typescriptlang.org/tsconfig#isolatedDeclarations)\n/// rules: every exported value needs an explicit type annotation.\n///\n/// Fresh runs this over every TypeScript plugin at load time so the\n/// plugin's public types (anything the file `export`s plus any\n/// `declare global` / module-augmentation blocks) are available to","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/sinelaw/fresh/blob/67894ca5463dbd7a89bb31add4627c27d6b79d83/crates/fresh-parser-js/src/lib.rs#L36-L72","documentation":"The final TypeScript-stripping transform (oxc transformer) reported errors inside `transpile_typescript`; the pipeline stops before codegen and returns them joined by '; '. Parse and semantic stages passed but the type-removal pass itself failed.","triggerScenarios":"Calling `transpile_typescript` on code whose transform step errors — uncommon; usually indicates oxc-unsupported syntax combinations or an internal transformer edge case in exotic TS constructs.","commonSituations":"Cutting-edge or unusual TypeScript decorators/enums/namespace constructs in a plugin; an oxc version bug triggered by specific syntax.","solutions":["Read the listed transform errors and simplify/rewrite the offending TypeScript construct (e.g. avoid exotic decorators or const enums).","Update the oxc dependency to get transformer fixes.","Precompile the plugin with tsc/esbuild to plain JS and load that instead of transpiling at runtime."],"exampleFix":"// before\nexport const enum Speed { Fast } // const enum can trip the transformer\n// after\nexport enum Speed { Fast }","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"let js = match transpile_typescript(ts_src, \"plugin.ts\") {\n    Ok(js) => js,\n    Err(e) if e.to_string().starts_with(\"Transform errors\") => precompiled_js.clone(), // esbuild output fallback\n    Err(e) => return Err(e),\n};","preventionTips":["Avoid exotic TS features (const enums, legacy decorators) in plugins.","Precompile plugins to JS with esbuild/tsc when possible.","Keep oxc updated for transformer fixes."],"tags":["typescript","transformer","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"}