Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code - Adjust import quotation setting

When working in TypeScript in Visual Studio Code, the import suggestion on a type (triggered by space + period) will generate an import using double quotes.

Our TypeScript linter verifies that single quotes are used where possible.

As you can see below, the suggestion has double quotes ("@angular/...") Import suggestion with double quotes

How can I adjust the setting of the import?

like image 280
Boris van Katwijk Avatar asked Mar 22 '17 13:03

Boris van Katwijk


People also ask

How do I optimize imports in VSCode?

In VSCode, go to File -> Preferences -> Settings and click on the icon in the top right hand corner to open up the settings in JSON. Et voilà! Your imports will now be organized every time you save a file.


2 Answers

As of VSCode 1.10, this is (sadly) not possible yet. But is an issue for a lof of the users as it seems. The VSCode theme is aware of this issue and you can follow this to know when it is implemented: https://github.com/Microsoft/TypeScript/issues/13270


Update June 2018

Since VSCode 1.24 (June 2018) there is an option for this!

"typescript.preferences.quoteStyle": "single" 

For more info see:

https://code.visualstudio.com/updates/v1_24#_preferences-for-auto-imports-and-generated-code

like image 114
Sebastian Sebald Avatar answered Oct 12 '22 13:10

Sebastian Sebald


You can also configure the below line in your vscode user settings to adjust this setting.

"prettier.singleQuote": true 
like image 43
abdllhbyrktr Avatar answered Oct 12 '22 12:10

abdllhbyrktr