We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2
Debug the script in visual studio code
> Open the terminal in VSCode and check typescript version
tsc -v > Initializa typescript tsc -init The above command will create tsconfig.json file > In the default JSON file you can see the below configuration: { "compilerOptions": { "target": "es6", "module": "commonjs", "sourceMap": true, ----> Add this to config file "outDir": "./dist" ----> Add this to config file and change the path to Project workspace or any folder where you want to save }, "include": ["*.ts"] ----> Add this to config file and it is mandatory, without this you cannot debug the typescript files } > Compile the typescript code tsc tsc <scriptname>.ts --watch The above command will generate .js file
> Run .js file and check if it is running properly and getting the expected output (Optional step) node <scriptname>.js
> Configure Build task in VSCode
> To create task in VSCode, click on ctrl+shift+p > Type Tasks: Configure Task and select TypeScript: tsc - build The above command will create tasks.json file which will help user run tsc: build - tsconfig.json > In tasks.json file, user can see the below code { "version": "2.0.0", "tasks": [ { "type": "typescript", "tsconfig": "tsconfig.json", "problemMatcher": ["$tsc"], "group": { "kind": "build", "isDefault": true ---->Add this step to config file }, "label": "tsc: build - tsconfig.json" } ] }
> Run the build task,
Press Ctrl + Shift + B in Visual Studio Code to run the default build task (tsc: build - tsconfig.json). If the task is configured correctly, TypeScript will compile your files as per the tsconfig.json settings. > Configure Debugging Open Debug Panel: Go to the Debug view (Ctrl + Shift + D). Click "create a launch.json file". > Check the debug configuration in launch.json file { "version": "0.2.0", "configurations": [ { "type": "node", "request": "launch", "name": "Launch Program", "program": "${workspaceFolder}/dist/variables.js", // Update path if needed "outFiles": ["${workspaceFolder}/dist/**/*.js"], "preLaunchTask": "tsc: build - tsconfig.json", "console": "integratedTerminal" } ] } ----> Make sure the script compiled successfully and have the respective .js file > Add Break points in the script > Start Debugging In the Debug panel, select "Launch Program" from the dropdown. Click on 'Run' button or F5 > The debugger will stop the execution at the break point
JavaScript Fundamentals: JavaScript Syntax, What JavaScript is Use for in Website Development, JavaScript Variable, Strings, Popup Boxes, JavaScript Objects, Function, and Event Handlers