Microsoft has released the stable version of their new TypeScript compiler written in golang which they claim 10x faster than the previous TypeScript based implimentation. While I can't speak for 10x claim, it is definitely magnitudes faster in my old crappy dual core dev laptop. So you might feel some benifits based on the complexitity of your codebase and machine's performance.
Alright, enough chitchat, let's see how to get this wired into our sweat neovim editor. And btw this guide is for neovim's native LSP client. If you still use nvim-lspconfig I highly recommend you to move all your lsp configs to the native API.
Prerequisites
- Neovim v11+
- npm (or your package manager of choice)
Steps
- Download and install the new typescript version from npm registry.
npm i -g typescript
- Check version. It should show v7.0.0 or above.
tsc --version
- Add the server to the
init.luafile or define it in a new file and import toinit.lua.
-- define the LSP server
vim.lsp.config['tsc'] = {
cmd = {'tsc', '--lsp', '--stdio'},
filetypes = {'javascript', 'javascriptreact', 'typescript', 'typescriptreact'},
root_markers = {'package.json', 'tsconfig.json', '.git'},
}
-- enable
vim.lsp.enable('tsc')
- Open up a TypeScript/JavaScript project and test.
- Upon exploring a huge codebase, you should feel the snapiness in goto definitions, references and completions popup.
Enjoy writing TypeScript!


Top comments (0)