sinelaw/fresh · error

Transform errors

Error message

Transform errors: {}

What it means

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.

Solutions

  1. Read the listed transform errors and simplify/rewrite the offending TypeScript construct (e.g. avoid exotic decorators or const enums).
  2. Update the oxc dependency to get transformer fixes.
  3. Precompile the plugin with tsc/esbuild to plain JS and load that instead of transpiling at runtime.

Example fix

// before
export const enum Speed { Fast } // const enum can trip the transformer
// after
export enum Speed { Fast }
Defensive patterns

Strategy: fallback

Try / catch

let js = match transpile_typescript(ts_src, "plugin.ts") {
    Ok(js) => js,
    Err(e) if e.to_string().starts_with("Transform errors") => precompiled_js.clone(), // esbuild output fallback
    Err(e) => return Err(e),
};

Prevention

When it happens

Trigger: 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.

Common situations: Cutting-edge or unusual TypeScript decorators/enums/namespace constructs in a plugin; an oxc version bug triggered by specific syntax.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of sinelaw/fresh@67894ca546 (2026-09-13). Data as JSON: /api/errors/26e411992a5dcffe. Report an issue: GitHub.

Appendix: source

Thrown at crates/fresh-parser-js/src/lib.rs:54

        let errors: Vec<String> = semantic_ret.errors.iter().map(|e| e.to_string()).collect();
        return Err(anyhow!("Semantic errors: {}", errors.join("; ")));
    }

    // Get scoping info for transformer
    let scoping = semantic_ret.semantic.into_scoping();

    // Transform (strip TypeScript types)
    let transform_options = TransformOptions::default();
    let transformer_ret = Transformer::new(&allocator, Path::new(filename), &transform_options)
        .build_with_scoping(scoping, &mut program);

    if !transformer_ret.errors.is_empty() {
        let errors: Vec<String> = transformer_ret
            .errors
            .iter()
            .map(|e| e.to_string())
            .collect();
        return Err(anyhow!("Transform errors: {}", errors.join("; ")));
    }

    // Generate JavaScript
    let codegen_ret = Codegen::new().build(&program);

    Ok(codegen_ret.code)
}

/// Emit a TypeScript declaration file (`.d.ts`) from TypeScript source.
///
/// Uses oxc's isolated-declarations transformer — no full type checker is
/// required, but the source must follow TypeScript's
/// [isolated declarations](https://www.typescriptlang.org/tsconfig#isolatedDeclarations)
/// rules: every exported value needs an explicit type annotation.
///
/// Fresh runs this over every TypeScript plugin at load time so the
/// plugin's public types (anything the file `export`s plus any
/// `declare global` / module-augmentation blocks) are available to

View on GitHub (pinned to 67894ca546)