Emacs and TypeScript

There are a few packages for TypeScript supporting in Emacs, most of them are not great or limited (only support syntax highlighting, indenting,… doesn't has live checking). Even lsp already supported TypeScript, but it's isn't so great for me, there's a big performance problem that even slow you down when you typing.

After switching between packages, I finally found tide is a great one. Comparing to the experience in VSCode, I can say tide is even better. It provides a great error checking, linting, and auto completion.

This is my config, using use-package and combining with js2-mode:

;; JavaScript and TypeScript
(use-package js2-mode
  :ensure t
  (add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode)))

(use-package tide
  :ensure t
  :after (typescript-mode company flycheck)
  :hook ((typescript-mode . tide-setup)
         (typescript-mode . tide-hl-identifier-mode)
         (before-save . tide-formater-before-save)))

(use-package web-mode
  :ensure t
  (add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))
  (add-to-list 'auto-mode-alist '("\\.tsx\\'" . typescript-mode))
  (setq web-mode-enable-current-element-highlight t))

Date: 2019-01-27 Sun 00:00

Author: Huy Tran

Created: 2019-04-22 Mon 14:41