Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
img Use + instead of ! for layer categories Sep 11, 2015
README.org Update README.org Apr 1, 2017
config.el Bump year in copyright headers Apr 2, 2017
funcs.el Bump year in copyright headers Apr 2, 2017
packages.el Bump year in copyright headers Apr 2, 2017

README.org

TypeScript layer

img/TypeScript.png

Table of Contents

Description

This layer adds support for TypeScript and TSX editing.

This layer provides:

  • Eldoc-mode
  • Documentation at point
  • Auto complete
  • Flycheck with linter
  • Jump to definition, Jump to type definition
  • Find occurrences (Imenu-mode)
  • Rename symbol
  • tsx mode
  • formatting
  • TypeScript playground integration

Install

Pre-requisites

You will need node.js v0.12.0 or greater

If you want linting run: npm install -g typescript npm install -g tslint

If you want to use typescript-formatter for formatting run: npm install -g typescript-formatter

For best results, make sure that the auto-completion (company) and html layers are enabled.

Layer

To use this configuration layer, add it to your ~/.spacemacs. You will need to add typescript to the existing dotspacemacs-configuration-layers list in this file.

(setq-default dotspacemacs-configuration-layers '(typescript))

If you need formatting on save:

(setq-default dotspacemacs-configuration-layers '(
  (typescript :variables
              typescript-fmt-on-save t)))

You can choose formatting tool:

(setq-default dotspacemacs-configuration-layers '(
  (typescript :variables
              typescript-fmt-tool 'typescript-formatter)))

Default is ‘tide .

Notes

This layer uses:

The tools use configuration files. You can learn more in their documentation.

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.

Send to playground requires browser.

Currently tsserver doesn’t pickup tsconfig.json file changes. You might need to restart server after editing it.

Key bindings

Typescript Major Mode

Key BindingDescription
SPC m =reformat the buffer
SPC m g bjump back
SPC m g gjump to entity’s definition
SPC m g tjump to entity’s type definition
SPC m g ureferences
SPC m h hdocumentation at point
SPC m r rrename symbol
SPC m s psend selected region or current buffer to the web playground
SPC m S rrestart server

Reference Major Mode

Key BindingDescription
C-jfind previous reference
C-kfind next reference
C-lgoto reference
You can’t perform that action at this time.