Visual Studio Code - Adjust import quotation setting

后端 未结 10 1063
广开言路
广开言路 2021-02-02 04:56

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 TypeScri

相关标签:
10条回答
  • 2021-02-02 05:39

    As of TypeScript 2.5, the first import or export statement in the file will be scanned to determine if single or double quotes are used when using import suggestions.

    https://github.com/Microsoft/TypeScript/pull/17750

    0 讨论(0)
  • 2021-02-02 05:40

    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

    0 讨论(0)
  • 2021-02-02 05:41

    An alternative which does support this configuration is TypeScript Toolbox.

    It is configurable by setting genGetSet.pathStringDelimiter, which already has the single-quote import as default.

    0 讨论(0)
  • 2021-02-02 05:41

    Above solutions did not work for me

    So here is my work around, in you use vscode, "tslint.autoFixOnSave": true in your settings.json will automatically fix these import quotations when you save the file.

    0 讨论(0)
提交回复
热议问题