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
kdy1
kdy110mo ago
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.
xnor
xnor2mo ago
are there updated examples for this? the link there 404s I'm also using the Rust API
kdy1
kdy12mo ago
The crate name is now swc_ts_fast_strip
xnor
xnor2mo ago
yeah, but i don't see any examples in there? oh.. i see 'in the main repository"
xnor
xnor2mo ago
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?
magic-akari
magic-akari2mo ago
The idea behind 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.
xnor
xnor2mo ago
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

Did you find this page helpful?