Even though I diligently followed the tutorial provided by vscode on compiling typescript code, I encountered a problem. The configurations were set up as per the instructions in the tutorial, but when I tried to run the code without debugging, I received the following error message:
Cannot launch program '/Users/username/Desktop/work/ts/main.ts' because corresponding JavaScript cannot be found.
Strangely enough, running the command "tsc" in the terminal resolved the issue, and the code ran successfully using "Run -> Run without Debugging".
The snippet of code from "main.ts" is as follows:
let a : Array<number> = [1,2,3]
let b : number[] = a
console.log(a === b)
Below are the contents of tsconfig.json:
{
"compilerOptions": {
"target": "es5",
"module": "esnext",
"outDir": "out",
"sourceMap": true,
}
}
Here's an excerpt from launch.json:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}/main.ts",
"outFiles": [
"${workspaceFolder}/**/*.js"
]
}
]
}
And lastly, tasks.json contains:
{
"version": "2.0.0",
"tasks": [
{
"type": "typescript",
"tsconfig": "tsconfig.json",
"problemMatcher": [
"$tsc"
],
"group": {
"kind": "build",
"isDefault": true
},
"label": "tsc: build - tsconfig.json"
}
]
}