-
- Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Description
Describe the bug
I think this was a breaking change since the error is emitted as a string, which is unexpected and slightly unconvinient. The expectation was to keep emitting an js object error.
The main issue is that:
- json parsing adds some overhead and it has to be done ALWAYS since string is not useful
- makes error handling weird/inconsistent since swc wasm crashes are also strings so we try to json.parse and it fails while right now if its a string we know its a wasm crash
Input code
const inputCode = "module F { export type x = number }"; try { transformSync(inputCode, { mode: "transform", }); } catch (error) { console.log("TYPEOF OF ERROR", typeof error); assert.strictEqual(error.code, "UnsupportedSyntax"); } TYPEOF OF ERROR stringConfig
Playground link (or link to the minimal reproduction)
SWC Info output
No response
Expected behavior
Emit an object
Actual behavior
Emits a string
Version
1.11.7
Additional context
No response