in webstorm typescript scratch ~ read.

Running Typescript scratches in Webstorm IDE

Recently i started to work more closely with Typescript and therefore i need to test some small ideas more often in typescript. Scratches are the best place to do that while you're building something. Unfortunatelly Webstorm doesn't support running typescript scratches out of the box. It can only understand Js files. I wasn't excited about this, but i managed to find a quick solution to this. Hope it will help others as well.

  1. First we need to install ts-node package with npm install -g ts-node command
  2. Create typescript scratch in Webstorm IDE
  3. Cmd + Shift + A -> Edit Configuration
  4. Create new Node configuration with next settings :
    Screenshot-2020-08-24-at-14.45.50-1

The key here is to specify --require ts-node/register in Node parameters section. This will tell IDE to transpile ts scratch file into js file and run it.

Thanks Elena Pogorelova for this tip !

comments powered by Disqus
comments powered by Disqus