# TypeScript
# Building, Debugging and Running TS
# With Chrome
See the video Debug Node.js apps with Chrome DevTools and TypeScript
We set a debugger
statement inside the code to stop the execution. for instance for the filefindbug.ts
:
class FindBug {
findBugg(bug: string) {
console.log(`Finding this ${bug} on my program!`)
}
}
debugger;
const bugs: FindBug = new FindBug()
console.log(bugs.findBugg('Spider'))
2
3
4
5
6
7
8
We run the .js generated file with --inspect-brk
:
node --inspect-brk fordebug/findbug.js
we must compile the .ts source with the sourceMap
option activated:
tsc fordebug/findbug.ts --sourceMap true`:
Here is an example:
➜ debug pwd
/Users/casianorodriguezleon/campus-virtual/2122/learning/typescript-learning/debug
➜ debug npm run debug
> debug@1.0.0 debug
> npm test; node --inspect-brk fordebug/findbug.js
> debug@1.0.0 test
> tsc fordebug/findbug.ts --sourceMap true
Debugger listening on ws://127.0.0.1:9229/013ee471-d752-447a-904e-6037b8d236d1
For help, see: https://nodejs.org/en/docs/inspector
2
3
4
5
6
7
8
9
10
11
12
13
Here is a screenshot of a session with chrome after visiting chrome://inspect
:
# With VSCode
Watch Build and Debug NodeJS Typescript with ONLY VSCODE. Basarat Codes (opens new window) Youtube
In addition I had to install as development dependencies locally:
ts-node and ts-config-paths
This is the launch.json
file used to debug gh-edu.ts
:
{
// Use IntelliSense para saber los atributos posibles.
// Mantenga el puntero para ver las descripciones de los existentes atributos.
// Para más información, visite: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "pwa-node",
"request": "launch",
"name": "debug gh-edu -h",
"skipFiles": [
"<node_internals>/**"
],
// "preLaunchTask": "tsc: build - tsconfig.json",
"program": "${workspaceFolder}/gh-edu.ts",
"runtimeArgs": [ "-r", "ts-node/register", "-r", "tsconfig-paths/register" ],
"args": [ "-h" ],
"console": "integratedTerminal",
"outFiles": [
"${workspaceFolder}/js/**/*.js"
]
}
]
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
special interest has the double asterics in /js/**/*.js
allowing the debugging of other files, not only the main one.
See
https://stackoverflow.com/questions/69326439/debug-multiple-files-in-typescript (opens new window)
"outFiles": [
"${workspaceFolder}/js/**/*.js"
]
2
3
# Introduction to TypeScript
# TypeScript - Tutorial desde CERO en Español 🏆
# Tutorial TypeScript con Node.js y Express. ¡Crea tu API REST con tipos estáticos DESDE CERO!
# Writing Modules in TypeScript
- Step by step: Building and publishing an NPM Typescript package (opens new window)
- TypeScript handbook: Publishing Declaration files (opens new window)
- Publishing what you mean to publish (opens new window)
- Create high quality npm packages using TypeScript (opens new window) video and repo by Basarat Ali Syed. Ahello world on how to publish an npm ts module
- Configuring nodemon with TypeScript (opens new window)
# Curso FullStack Open
El curso Profundización en el desarrollo web moderno
https://fullstackopen.com/es/ (opens new window)
📚 🧑💻 Presentación del curso y Fundamentos del Desarrollo Web - Bootcamp FullStack Gratuito
MiDuDev comienza aquí el Bootcamp FullStack gratuito con una introducción. Después de eso, una descripción general de los conceptos básicos del desarrollo web y también habla sobre los avances en el desarrollo de aplicaciones web durante las últimas décadas.
# References
- Build and Debug NodeJS Typescript with ONLY VSCODE. Basarat Codes (opens new window) Youtube
- TypeScript Documentation (opens new window)
- Cherny, Boris. Programming TypeScript. O'Reilly Media, 2019. Web (opens new window)
- BOGDANmanate/mvp-ts (opens new window) Bogdan Workshop repo with Conway's Game of Life