Skip to content

Commit

Permalink
fix: Remove Caused by: 'failed to parse' from TS blank space (#9820)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 authored Dec 29, 2024
1 parent fb2f6e4 commit aaeb0ab
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`transform in strip-only mode should not emit 'Caused by: failed to parse' 1`] = `
" x await isn't allowed in non-async function
,----
1 | function foo() { await Promise.resolve(1); }
: ^^^^^^^
\`----
"
`;

exports[`transform in strip-only mode should remove declare enum 1`] = `
{
"code": " ",
Expand Down
8 changes: 8 additions & 0 deletions bindings/binding_typescript_wasm/__tests__/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,13 @@ describe("transform", () => {
})
).rejects.toMatchSnapshot();
});

it("should not emit 'Caused by: failed to parse'", async () => {
await expect(
swc.transform("function foo() { await Promise.resolve(1); }", {
mode: "strip-only",
})
).rejects.toMatchSnapshot();
});
});
});
2 changes: 1 addition & 1 deletion bindings/binding_typescript_wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@ fn operate(input: String, options: Options) -> Result<TransformOutput, Error> {
}

pub fn convert_err(err: Error) -> wasm_bindgen::prelude::JsValue {
format!("{:?}", err).into()
format!("{}", err).into()
}

0 comments on commit aaeb0ab

Please sign in to comment.