Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deno REPL cannot recognize TypeScript variable declaration

I installed Deno 1.0.5 on Windows 10, using Chocolatey. I tried to use Typescript in the Deno REPL, but apparently it cannot recognize TypeScript variable declarations if the type is set:

 C:\>deno
 Deno 1.0.5
 exit using ctrl+d or close()
 > let x: number;
 Uncaught SyntaxError: Unexpected token ':'
     at evaluate ($deno$/repl.ts:54:34)
     at Object.replLoop ($deno$/repl.ts:156:13)
 > let x: number = 42;
 Uncaught SyntaxError: Unexpected token ':'
     at evaluate ($deno$/repl.ts:54:34)
     at Object.replLoop ($deno$/repl.ts:156:13)
 > let x = 42;
 undefined
 > x
 42

Do I need to do something special to make Deno CLI support TypeScript?

like image 425
kol Avatar asked Dec 11 '25 17:12

kol


1 Answers

Deno REPL does not support typescript yet.

See the following old issue: https://github.com/denoland/deno/issues/1158 which is still open.

Comment from Ryan Dahl on a PR that adds TS support:

Feb 24, 2020

Just a bit more context for future researchers: There are many things we can do to improve the REPL without introducing the TS compiler. We should do those things first (e.g. improve inspect, tab completion). Once we're on par with Node's REPL, we can start looking into how to go beyond that by using typescript.

like image 198
Marcos Casagrande Avatar answered Dec 13 '25 09:12

Marcos Casagrande