/tide

Tide - TypeScript Interactive Development Environment for Emacs

Primary LanguageJavaScript

Tide

TypeScript Interactive Development Environment for Emacs

screencast

Installation

  • Install node.js v0.12.0 or greater.
  • Tide is available in melpa. You can install tide via package-install M-x package-install [ret] tide
;; sample config
(add-hook 'typescript-mode-hook
          (lambda ()
            (tide-setup)
            (flycheck-mode +1)
            (setq flycheck-check-syntax-automatically '(save mode-enabled))
            (eldoc-mode +1)
            ;; company is an optional dependency. You have to
            ;; install it separately via package-install
            (company-mode-on)))

;; aligns annotation to the right hand side
(setq company-tooltip-align-annotations t)

;; Tide can be used along with web-mode to edit tsx files
(require 'web-mode)
(add-to-list 'auto-mode-alist '("\\.tsx\\'" . web-mode))
(add-hook 'web-mode-hook
          (lambda ()
            (when (string-equal "tsx" (file-name-extension buffer-file-name))
              (tide-setup)
              (flycheck-mode +1)
              (setq flycheck-check-syntax-automatically '(save mode-enabled))
              (eldoc-mode +1)
              (company-mode-on))))

Notes

  • Make sure to add tsconfig.json in the project root folder.

  • tsserver mangles output sometimes issue - #2758, which will result in json parse error. Try node version 0.12.x if you get this error.

Commands

Keyboard shortcuts Description
C-c d Show documentation for the symbol at point.
M-. Jump to the definition of the symbol at point. With a prefix arg, Jump to the type definition.
M-, Return to your pre-jump position.

M-x tide-restart-server Restart tsserver. Currently tsserver doesn't pickup tsconfig.json file changes. This would come in handy after you edit tsconfig.json.

M-x tide-references List all references to the symbol at point in a buffer. References can be navigated using n and p. Press enter to open the file.

M-x tide-rename-symbol Rename all occurrences of the symbol at point.

Features

  • ElDoc
  • Auto complete
  • Flycheck
  • Jump to definition, Jump to type definition
  • Find occurrences
  • Rename symbol
  • Imenu