Monday, March 14, 2016

How to use TypeScript in Sublime Text Editor

Hi All,


If you are trying to use TypeScript features in Sublime Text 3. This blog post describes step by step on how to start coding and utilize TypeScript features including intelliSense, compile time checking, validation...etc in Sublime.

Follow this walkthrough:

1) You need to have Package Control in Sublime, if you do not have it follow below steps. otherwise, continue reading step 2.

  • Open sublime text console by clicking on the top menu: View --> Show Console

  • Upon opening the console, you will see the console shows at the bottom of sublime

  • Copy this text in the console

import urllib.request,os,hashlib; h = '2915d1851351e5ee549c20394736b442' + '8bc59f460fa1548d1514676163dafc88'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)
  • Close and re-open sublime text 3
2) We need to install TypeScript from Package Control by searching for this package. To open package control, We need to open Command Palette from tools menu.



3) Then type Install Package in the popup window.



4) Package Control will popup and then search for TypeScript plugin by writing: TypeScript and then select the package.

Note: you will notice i do not have typescript screenshot since it is already installed on sublime

5) Now, try to add any TypeScript file (with .ts extension) and you will be able to use TS features while writing code in Sublime Text!



Enjoy!


No comments: