The code above is invalid, but
tsc accepts it and print an error message for it. I decided to follow the behavior of
tsc and I modified the parser to accept it.
Because some runtimes support private properties, I implemented printing logic for private properties.
An example use case is deno, which uses v8.
This was problematic if you use only typescript stripper. Code generator for a catch clause emitted
) regardless of existence of the parameter.
Now you can use the optional catch binding syntax without the optional catch binding pass.
Previously, the code below was miscompled, because the transform didn't visit children.
This is fixed by visiting children.
Previously swc miscompiled readonly properties.
Readonly is now properly handled.
Previously, swc ignored the original quote of a string literal. This was intentional, and the purpose is to make output smaller by reducing the number of backslashes. But it is too bad for rust users, so I changed
swc_ecma_codegen to preserve quotes.
The bug is occured by two facts
- swc did not check for duplicate comments.
- TypeScript parser requires backtracking.
While backtracking, swc simply added comments to the comment storage, and didn't care about duplicate comments. If backtracking is successful, there's no problem. But if backtracking fails, cursor of the lexer goes back without removing comments. This is fixed by tracking last position of comments. Now there's two cursor in the lexer - one for code, one for comments. The comments cursor does not go back, so even if backtracking is failed, it remains as-is and duplicated comments are simply ignored.