I am learning typescript with visual studio code in Windows 10 and I am getting an error to run simple program.
"Cannot launch program 'E:\typescriptBasis\main.ts' because corresponding JavaScript cannot be found." hence I am not able to debug code.
I have installed nodejs version v10.2.1
I have installed npm version v5.6.0
I have installed typescript globally v2.8.3
I have installed Visual sudio code v1.23.1
launch.json file
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"sourceMaps": true,
"name": "Launch Program",
"program": "${workspaceFolder}/main.ts",
"outFiles": [
"${workspaceFolder}/**/*.js"
]
}
]
}
tsconfig.json file
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"sourceMap": true
}
}
tasks.json
{
"version": "2.0.0",
"tasks": [
{
"type": "typescript",
"tsconfig": ".vscode\\tsconfig.json",
"option": "watch",
"problemMatcher": [
"$tsc-watch"
]
},
{
"type": "typescript",
"tsconfig": ".vscode\\tsconfig.json",
"problemMatcher": [
"$tsc"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
main.ts file
console.log("this is my first program of typescript");
I have it working with the following launch.json:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"preLaunchTask": "TSC",
"program": "${file}",
"outFiles": [
"${workspaceFolder}/**/*.js"
]
}
]
}
tsconfig.json:
{
"compilerOptions": {
"target": "esnext",
"module": "commonjs",
"allowJs": false,
"sourceMap": true,
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"esModuleInterop": true
}
}
and tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"label": "TSC",
"type": "typescript",
"tsconfig": "tsconfig.json",
"problemMatcher": [
"$tsc"
]
}
]
}
And my current version of VS Code is 1.28.2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With