Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebStorm/PhpStorm double quotes in TypeScript auto import

I'm using TypeScript style with single quotes, double quotes are used exclusively in HTML templates.

WebStorm/PhpStorm auto import adds import statements with double quotes and ruins the style. I guess this applies to all JetBrains products.

How can this behaviour be fixed?

like image 217
Estus Flask Avatar asked Sep 29 '16 20:09

Estus Flask


People also ask

How do you auto import on Webstorm?

In the Settings/Preferences dialog ( Ctrl+Alt+S ), go to Editor | General | Auto Import. On the Auto Import page that opens, use the checkboxes in the TypeScript/JavaScript area to enable or disable import generation on code completion.

How do I sort imports in Webstorm?

If we want to go a step further and sort the imports, we can go to Preferences / Settings | Editor | Code Style | JavaScript or TypeScript and select Sort imports by modules on the Imports tab.

Do not import exactly from?

The option “Do not import exactly from” allows you to tell the IDE that you don't want any imports that are from the specific path (e.g. @material-ui/core ) or path pattern (e.g. @material-ui/core/** ). The IDE will then use an alternative path if there is one.


2 Answers

This behaviour is controlled by the following option:

  1. Settings/Preferences
  2. Editor | Code Style | TypeScript
  3. "Punctuation" tab | Generated code -> Quote marks

As of 2017.1 version it's on new Punctuation tab and options are named a bit differently:

enter image description here

like image 154
LazyOne Avatar answered Oct 18 '22 15:10

LazyOne


Also if you would like to add automatic space between curly braces when adding imports like so

import { MyComponent } from './my.component';

you may check in tab Spaces | Whithin | ES6 import/export braces

like image 45
Leo Avatar answered Oct 18 '22 15:10

Leo