DEV Community

Cover image for How I set up my emacs for TypeScript + React

How I set up my emacs for TypeScript + React

Laura Viglioni on October 11, 2020

What exactly is my point here? I recently knew typescript and with it, some joy and some tears. For a very long time, I've been working ...
Collapse
 
davidasg180 profile image
David Alberto Serrano Garcia • Edited

Hi,
Taking for reference your video, at the second 00:10 you import map and when you accept the auto-complete and it automatically add the import on the top.
in vscode and neovim on both I manage to do that, but i don't know what i'm doing wrong to not making work that feature in spacemacs.
What tool or configuration make possible to achieve that?
It's a Typescript React environment
Thanks a lot

Collapse
 
lucasmafra profile image
Lucas Mafra

Hi David, import-js is what you're looking for github.com/Galooshi/emacs-import-j...

Collapse
 
viglioni profile image
Laura Viglioni

I had problems with import-js, that's why I removed from this text. Tide should be enough for auto importing 🤔

Collapse
 
viglioni profile image
Laura Viglioni

I'm sorry for the delay if I'm not mistaken the company package does that.

If it helps those are my configs about js/ts:

github.com/Viglioni/spacemacs/blob...
github.com/Viglioni/spacemacs/blob...
github.com/Viglioni/spacemacs/blob...

Collapse
 
llemaitre19 profile image
Loïc Lemaître

Starting Emacs 29.1, there is the built-in tsx-ts-mode major mode for editing Typescript + JSX. You could also be interested by jtsx package that extends tsx-ts-mode (and js-ts-mode too) to provide some handy additional functionalities.

Collapse
 
emaphp profile image
Emmanuel Antico

why not lsp though? I'm confused about the fact that the major-mode shown is web, instead of React (which is a layer too). you can force that mode doing M-x and then rjsx-mode.

Collapse
 
viglioni profile image
Laura Viglioni

Yes! I'm trying lsp now and i think it is great, I will soon write a text about my TS config with LSP :)

it is quite easier than with tide and better.

Collapse
 
hagenek profile image
Georg H. Ekeberg

Hi. Please write that text! I am configuring now and need some assitance. Thanks for writing the first post also.

Collapse
 
rajasegar profile image
Rajasegar Chandran

This is the perfect tutorial I have been looking for, thank you

Collapse
 
viglioni profile image
Laura Viglioni

thx!

Collapse
 
bobbybakes profile image
Bobby Baker

Great stuff!

Collapse
 
viglioni profile image
Laura Viglioni

thx!

Collapse
 
tosiek88 profile image
Mateusz

Any chance for vue+typescript, this really sad that vue-mode is no longer develop ;(

Collapse
 
viglioni profile image
Laura Viglioni

ooh :(
I never used vue :(

Collapse
 
alechstong profile image
Alex Tong

Hi Laura, why do you need import-js. Doesn't Tide do auto-import already?

Collapse
 
viglioni profile image
Laura Viglioni

As a matter of fact yes! I used to format imports on save, but it is not necessary :)