Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatic TypeScript `import` formatting in Visual Studio Code

I'm working on an Angular 9 project in Visual Studio Code. When I type the name of an existing TypeScript class, I press Ctrl + . to import it automatically. How can I configure the auto-import functionality to use double quotes and relative paths instead of single quotes and absolute paths?

Example:

  • I get this: import { RefreshService } from 'src/app/services/refresh.service';
  • I want this: import { RefreshService } from "../../services/refresh.service";

Thanks!

like image 210
kol Avatar asked Mar 07 '26 15:03

kol


2 Answers

OPen visual studio and open File -> preferences->settings and search auto import see image select extension TypeScript and change drop down option(Quote style) auto to double.

like image 139
PrakashT Avatar answered Mar 09 '26 05:03

PrakashT


The following two lines had to be added to .vscode/settings.json:

"typescript.preferences.importModuleSpecifier": "relative",
"typescript.preferences.quoteStyle": "double"
like image 36
kol Avatar answered Mar 09 '26 06:03

kol



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!