Skip to content

Instantly share code, notes, and snippets.

@gmocamilotd
Last active October 4, 2017 03:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gmocamilotd/91144c7d459c9c90a4d05b6cc132a5f9 to your computer and use it in GitHub Desktop.
Save gmocamilotd/91144c7d459c9c90a4d05b6cc132a5f9 to your computer and use it in GitHub Desktop.
1. take a look at [Chrome Devtools](https://developer.chrome.com/devtools) (given you use Chrome which has very neat devtools build-in).
2. I also often suggest people to do the [free Code School course](http://discover-devtools.codeschool.com/) on Discover Devtools which is nice as well.
3. Open web developer console, go to "Sources" section. Press "CTRL+P". A search box will open where type ".ts" and find your file or directly search your file like "myfile.ts". Open it and you can put breakpoints directly in the code, the same way we put breakpoints in a js file and Voila, you can debug Typescript.
4. In the case of TypeScript, also make sure that you enable sourcemaps. As you probably know TypeScript isn't directly executed by the browser, but rather it is being "compiled" (or as it's called "transpiled") into JavaScript. That said, you probably don't wanna debug the transpiled JS but rather the TypeScript code you wrote. To enable sourcemaps, set the proper flag in your __tsconfig.json__:
```
{
"version": "1.6.2",
"compilerOptions": {
...
"sourceMap": true
},
"exclude": [
...
]
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment