VS Code Run extension - no output shown from running program

588 views Asked by At

Recently I have tried Deno and since it has native TypeScript support, I thought it would be neat to use it as a "typescript runner". For example in Node you would write node server.js and in Deno would be like deno run -A server.ts and all of this in the code runner extension.

In vscode settings.json :

"code-runner.executorMap": {    
    "javascript": "node",
    "typescript": "cd $dir && deno run -A $fileName"       
}

Consider the following ts file "index.ts" :

const add = (a: number,b: number):number =>{
    console.log(a+b);
    return a+b;
}

add(1,2);

Output when running using the extension :

[Running] deno run -A index.ts
[33m3[39m

[Done] exited with code=0 in 0.082 seconds

Output when using the terminal cmd/powershell :

C:\Users\Oliver\Desktop\DenoPJ>deno run -A index.ts
3

Any thoughts about why it works inside the terminal and not inside the extension ?

2

There are 2 answers

0
jps On BEST ANSWER

I tried and could reproduce the problem.

When you change the settings under "Run Code configuration" to "Run in Terminal"

enter image description here

and then run the code again with AltCtrlN, VSCode will switch to the Terminal window and you should see:

PS C:\Users\jps\source\deno> cd "c:\Users\jps\source\deno\" ; if ($?) { deno run -A index.ts }
3
0
Morani On

Try to add flags to command (depends on your actions of application):

deno run --allow-net --allow-read --allow-write --allow-env index.ts