1:1 line number mapping
Is there a way to have line numbers in typescript be the same line numbers as javascript? For example, if there's a statement on line 17 in the TS source, SWC would put it on line 17 in the generated JS
I'm using the Rust API
9 Replies
See https://rustdoc.swc.rs/swc_fast_ts_strip/fn.operate.html and related examples in the main repository
operate in swc_fast_ts_strip - Rust
API documentation for the Rust
operate
fn in crate swc_fast_ts_strip
.are there updated examples for this? the link there 404s
I'm also using the Rust API
The crate name is now swc_ts_fast_strip
yeah, but i don't see any examples in there?
oh.. i see 'in the main repository"
GitHub
swc/bindings/binding_typescript_wasm/src at 4808875cceb2662ee03a697...
Rust-based platform for the Web. Contribute to swc-project/swc development by creating an account on GitHub.
great, thanks! I'm not seeing much in the docs about this, should I expect to be able to achieve 1:1 line number mapping?
The idea behind
https://bloomberg.github.io/ts-blank-space/
swc_ts_fast_strip
originated from ts-blank-space
. This approach introduces specific constraints on TypeScript that make it possible to safely strip its type annotations. If you're curious about the concept, you might want to check out the original explanation:https://bloomberg.github.io/ts-blank-space/
ts-blank-space
A small, fast, pure JavaScript type-stripper that uses the official TypeScript parser.
You can try out swc_ts_fast_strip in action on the SWC Playground! https://play.swc.rs/?version=1.13.2&code=H4sIAAAAAAAAA0WMQQqDMBBF93OKv6wgPYBpu5HewAvEQTA0Tcpkggvx7k2E4OrD%2B4%2FH3qaE0epjemEn4Jdn7xjb6tJnkTQg5O%2B8iLkutc4PmAwVxDEklcwa5cYxB21%2B37TurAJagvdWxROnba6r6gXXqfSgg0hXiRveIqXemT8eTB9GqwAAAA%3D%3D&config=H4sIAAAAAAAAA6vmUlBQyipOVrJSqAYygZyCxKLi1CI4HyhSXJlXklgBFFEqqSxILU4uyiwoUQJL1upA9JQkFqWnloBUpBYbGRiZgGTBckq5%2BSmlOakI00EmQNSZISnKzMtMqwQKpyXmFKeChTKLfWE6S4pKU7lqAVbq1jmpAAAA&strip-types=

oh interesting, by
specific constraints
.. i'll have to see if those work for my situation but this seems great
thanks a ton @magic-akari