TypeScript should use double quotes for string in import snippet.#22255
TypeScript should use double quotes for string in import snippet.#22255mjbvz merged 1 commit intomicrosoft:masterfrom adyavanapalli:master
Conversation
|
This seems like a small (but important) contribution, so no Contribution License Agreement is required at this point. We will now review your pull request. |
|
Thanks @adyavanapalli! This will be in the next insiders build |
|
Why can't this be configurable like tslint: https://palantir.github.io/tslint/rules/quotemark/ ? |
|
@tmcgannon This change only applies to the snippet and makes our behavior more consistent with TypeScript. Use the TSlint extension to autofix the snippet after insertion if you prefer single quotes (or just type of the import statement directly instead of using the snippet) |
|
I just wanna gather some context. This change was introduced because other similar vscode snippets use double quote? Or what? |
|
@mikehaas763 as noted, this PR was was to bring the snippet inline with the TS style guide |
|
Oh jeez not sure how I glossed over that. Makes sense. Although, I didn't see anywhere in the guide where it says double over single quotes. I'm sure it's in there though! |
|
@mikehaas763 Look here |
|
I agree with @tmcgannon why can't this be configurable. While the TS style guide says one thing lots of people use single quotes for strings instead of double quotes. To say just "Use the TSlint extension to autofix the snippet after insertion if you prefer single quotes (or just type of the import statement directly instead of using the snippet)" defeats the purpose of the feature and requires a lot of extra work. The idea of the snippet is to be a faster way to inserting the text but now you have made it virtually unusable for those who use single quotes for strings. |
|
@jmaronge This can be still configured by editing the typescript snippet file (Preferences > User Snippets > Typescript) and inserting the following configuration code: After, for the user-defined snippet to appear first in the list of available snippets (as now two snippet entries appear when you type As for why double quotes are configured by default: it is simply because vscode follows what is recommended by the typescript coding guidelines available here. If this truly bothers you and makes the snippet virtually unusable for those who use single quotes for strings, you can edit the system default snippet file, which is available (on Windows) at the following location: Cheers! XD |
|
@adyavanapalli so instead of providing a simple settings line where the default is double quotes, but that could be overridden in the user settings, you instead propose editing a local json file that cannot be included in my project source code repository? My tslint is configured to suggest single quotes.
There is no reason to not provide a setting for this. |
|
@linusbrolin I have provided two solutions. One in which the default double-quotes snippet can be overridden with a single-quotes snippet and these configuration files can be placed within your project's repo. This is all done from within vscode. The second solution is for those seeking a permanent change in the default setting. Please re-read my above response. |
|
As @adyavanapalli very well mentioned, you can edit the typescript.json file to get around this issue on Thx buddy. |
From style guide: https://github.com/Microsoft/TypeScript/wiki/Coding-guidelines #22231