Skip to content

Instantly share code, notes, and snippets.

@fedek6
Created June 24, 2021 13:27
Show Gist options
  • Save fedek6/29e1992be5233c3ce8466526c046e63c to your computer and use it in GitHub Desktop.
Save fedek6/29e1992be5233c3ce8466526c046e63c to your computer and use it in GitHub Desktop.
Working TypeScript debug example for Visual Studio Code
// src/index.ts
import { lubiePlacki } from "./placki";
function printMessage(msg: string): void {
console.log(`Message: ${msg}`);
}
printMessage("Hello, TypeScript");
debugger;
lubiePlacki();
// .vscode/launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"preLaunchTask": "npm: build",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}/dist/index.js"
}
]
}
{
"name": "typescript-fun",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "tsc-watch --onSuccess \"node ./dist/index.js\"",
"build": "tsc",
"list": "tsc --listFiles",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"tsc-watch": "^2.1.2",
"typescript": "^3.5.1"
}
}
// src/placki.ts
export const lubiePlacki = () => {
console.log("Lubie placki");
}
{
"compilerOptions": {
"target": "es2018",
"outDir": "dist",
"rootDir": "src",
"module": "commonjs",
"sourceMap": true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment