jsoldi
jsoldi5mo ago

How to transpile typescript to javascript?

I just read the Deno 2 announcement and would like to get started using it to replace npm+tsc+node. The problem is I usually work on projects that I transpile to javascript so they can run on a browser, and I do this with tsc. But tsc expects my local imports to end with '.js', while Deno expects my local imports to end with '.ts'. Is there a way to transpile a project where local imports ends in '.ts' (so they're compatible with Deno) into javascript. I read that Deno used to include a bundler but not anymore. What's the recommended way to use Deno to generate browser compatible JavaScript? Feel like I must just be missing something obvious here, unless Deno is just meant to be used for backend code.
3 Replies
marvinh.
marvinh.5mo ago
You might be interested in the upcoming TypeScript 5.7 which adds an option to support import specifiers to end with .ts. It's currently in beta, see https://devblogs.microsoft.com/typescript/announcing-typescript-5-7-beta/
jsoldi
jsoldiOP5mo ago
@marvinh. Nice. I feel like this is the correct approach and should've been that way from the very beginning. I'll give this a try
marvinh.
marvinh.5mo ago
agree, it's the only decision where I feel like the TS team made a mistake. I understand why they did it to keep the "just stripping types" ethos strong, but it's so much easier if you can just point to the actual files on disk. Happy to see that they are coming around

Did you find this page helpful?