March 15, 2020

Typescript function parameter Types

Defining a wrapper function with the same parameters as the inner function.

import { spawn } from 'child_process';

function customSpawn(...options: Parameters<typeof spawn>) {
  console.log('some custom code');
  
  return spawn(...options);
}

References:

typescript
February 28, 2020

Debugging web applications in vscode

Add this config in .vscode/launch.json

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "chrome",
      "request": "launch",
      "name": "Launch Chrome against localhost",
      "url": "http://localhost:3000",
      "webRoot": "${workspaceFolder}"
    }
  ]
}

This config is assuming that your web application is running at localhost:3000. This vscode launch config starts a new chrome process with remote debugging enabled. Now you can control the debug process through the vscode debugger interface.

Also make sure that source-maps are enabled for your dev server.

vscode javascript chrome