Alex Pinto
Alex Pinto

Reputation: 1

When I save any typescript files in vscode. All edited single quotes turns into double quotes

'@Component({
  selector: "message-list",
  templateUrl: "./message-list.component.html",
  styleUrls: ["./message-list.component.css"],'

What setting do I need to do when you save the file like selector:

 'message-list';
import { MessageVM } from "../message-section/message.vm" to import { MessageVM } from '../message-section/message.vm'

Upvotes: 0

Views: 915

Answers (3)

Moises Leonor
Moises Leonor

Reputation: 129

The problem can be related with the formatter, if you are using prettier formatter you can add .prettierrc file in the root of your project with the following configuration

{
    "singleQuote": true
}

Upvotes: 1

ulmas
ulmas

Reputation: 2253

If you are using the Prettier extension, see the other answers. If you don't have Prettier, then this should help:

Option 1 - JSON config:

  1. Open the settings JSON file (Command/Control + Shift + P) > Preferences: Open Settings (JSON)
  2. Add the following: "typescript.preferences.quoteStyle": "single"

Option 2 - UI config:

  1. Open the settings UI (Command/Control + Shift + P) > Prefrences: Open Settings (UI)
  2. Search for "typescript quote style" and set the value to single

Upvotes: 0

Kasunaz
Kasunaz

Reputation: 593

You can follow the below steps in order to disable that feature from the vscode. (If you have already installed the Prettier plugin with vscode )

File > Preferences > Settings

  • Then in the search bar search for singleQuote.
  • Then you can see a configuration like Prettier:Single Quote
  • Untick that.

So that it will never replace the double quotes with single quotes.

Upvotes: 1

Related Questions