I need to use native syntax for debugging, but amaro (swc) thinks it's invalid syntax. ```ts //@ts-expect-error %DebugPrint(null); ``` ``` //@ts-expect-error %DebugPrint(null); ^ SyntaxError [ERR_INVALID_TYPESCRIPT_SYNTAX]: Expression expected ```
Activity
acutmore commentedon Dec 3, 2025
Maybe you could use
eval("%DebugPrint(null)")?marco-ippolito commentedon Dec 5, 2025
I dont know if swc supports this syntax @kdy1
kdy1 commentedon Dec 5, 2025
No. It does not support such syntax atm. Does SWC should?
marco-ippolito commentedon Dec 5, 2025
Maybe behind a flag? So it does not throw when encountering this syntax.
So when user pass
--allow-native-syntaxwe enable itacutmore commentedon Dec 5, 2025
This syntax is specific to v8. It is neither valid TypeScript or JavaScript.
It is not parsed by
tsceither: https://www.typescriptlang.org/play/?#code/PTAEAEBcGcFoFMAeAHeBjSCBOWD2WAoAUgBF4AjAVwHMAFLASwDtIAKJygG04EoBuAkA(the%DebugPrint()becomes% DebugPrint()). It's just thattscwill still attempt to output JS even if there is a syntax error. In this particular case it turns out that v8 is OK will the re-printing of the input.In other invalid syntax cases TypeScript will insert a
;as the parser recovers:https://www.typescriptlang.org/play/?#code/PTAEAEBcGcFoFMAeAHeBjSCBOWD2WAoAO10lABJQA3AQwBsBLAEwG4g (
not $ validbecomesnot; $; valid;).