Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Functioning, up-to-date Emacs mode for TypeScript

Is there a reasonably functional, up-to-date, Emacs mode for TypeScript? There doesn't seem to be an official one, or least an official one that is actively updated.

There is a Microsoft one here, but it is old and doesn't incorporate the latest language changes (e.g. boolean as a keyword in addition to bool). This one looks similar, as does this one which claims to be more sophisticated.

All suffer from the following problem. In the example below, borderRadius is coloured differently from borderWidth and fontSize, presumably because the syntax colouring isn't coping properly with multiple variables introduced by a single var declaration.

var borderRadius: number = 4,
    borderWidth: number = 2,
    fontSize: number = 9;
like image 998
Roly Avatar asked Sep 23 '13 20:09

Roly


3 Answers

The up-to-date modes are the following: http://wikemacs.org/wiki/TypeScript

Tide

It is in MELPA so easy to install.

  • ElDoc
  • Auto complete
  • Flycheck
  • Jump to definition, Jump to type definition
  • Find occurrences
  • Rename symbol
  • Imenu
  • Compile On Save
  • Highlight Identifiers
  • Code Fixes

screencast:

Error checker

There is also an error checker, for flycheck, that uses tslint.

Spacemacs integration

Spacemacs has a Typescript layer: https://spacemacs.org/layers/+lang/typescript/README.html

it also includes an optional code formatter (https://github.com/vvakame/typescript-formatter).

see also

there is also emacs-tss that uses typescript-tools, but it is less active than the others. See the wiki.

like image 133
Ehvince Avatar answered Nov 12 '22 11:11

Ehvince


For the minimalist, there's also typescript.el. It

is a self-contained, lightweight and minimalist major-mode focused on providing basic font-lock/syntax-highlighting and indentation for Typescript syntax, without any external dependencies.

It supports tsc and tslint.

like image 43
serv-inc Avatar answered Nov 12 '22 12:11

serv-inc


emacs-tss includes a major mode, as you note. Since this package is maintained and available on MELPA, I suggest you use that and file these bugs there.

like image 2
Wilfred Hughes Avatar answered Nov 12 '22 11:11

Wilfred Hughes