Skip to content

Commit aaeb0ab

Browse files
authored
fix: Remove Caused by: 'failed to parse' from TS blank space (#9820)
1 parent fb2f6e4 commit aaeb0ab

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

Diff for: bindings/binding_typescript_wasm/__tests__/__snapshots__/transform.js.snap

+9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`transform in strip-only mode should not emit 'Caused by: failed to parse' 1`] = `
4+
" x await isn't allowed in non-async function
5+
,----
6+
1 | function foo() { await Promise.resolve(1); }
7+
: ^^^^^^^
8+
\`----
9+
"
10+
`;
11+
312
exports[`transform in strip-only mode should remove declare enum 1`] = `
413
{
514
"code": " ",

Diff for: bindings/binding_typescript_wasm/__tests__/transform.js

+8
Original file line numberDiff line numberDiff line change
@@ -130,5 +130,13 @@ describe("transform", () => {
130130
})
131131
).rejects.toMatchSnapshot();
132132
});
133+
134+
it("should not emit 'Caused by: failed to parse'", async () => {
135+
await expect(
136+
swc.transform("function foo() { await Promise.resolve(1); }", {
137+
mode: "strip-only",
138+
})
139+
).rejects.toMatchSnapshot();
140+
});
133141
});
134142
});

Diff for: bindings/binding_typescript_wasm/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,5 @@ fn operate(input: String, options: Options) -> Result<TransformOutput, Error> {
5353
}
5454

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

0 commit comments

Comments
 (0)