How can I see Deno transpiled javascript when writing in TypeScript?

Viewed 382

I'm learning Typescript using Deno and wanted do see javaScript result. Is there some command line I didn't see on docs?

ps.: I Know there's no compiling step using Deno, but at some point it must have a Javascript code so V8 engine can run it.

1 Answers

The transpiled code will be stored in

$DENO_DIR/gen

$DENO_DIR varies depending on the OS

  • On Linux/Redox: $XDG_CACHE_HOME/deno or $HOME/.cache/deno
  • On Windows: %LOCALAPPDATA%/deno (%LOCALAPPDATA% = FOLDERID_LocalAppData)
  • On macOS: $HOME/Library/Caches/deno If something fails, it falls back to $HOME/.deno

You can check the location doing:

deno info

Which will output:

DENO_DIR location: "/home/user/.cache/deno"
Remote modules cache: "/home/user/.cache/deno/deps"
TypeScript compiler cache: "/home/user/.cache/deno/gen"

If you do the following import:

import { serve } from 'https://deno.land/std@v0.51.0/http/server.ts'

You'll see the transpiled JavaScript code in:

$DENO_DIR/gen/https/deno.land/std@v0.51.0/http

Doing:

ls $DENO_DIR/gen/https/deno.land/std@v0.51.0/http

You'll see:

http_status.ts.js
http_status.ts.js.map
http_status.ts.meta
_io.ts.js
_io.ts.js.map
_io.ts.meta
server.ts.js
server.ts.js.map
server.ts.meta
Related