diff --git a/extensions/typescript-language-features/package.json b/extensions/typescript-language-features/package.json index 5bb2bbebc48..5efd464988d 100644 --- a/extensions/typescript-language-features/package.json +++ b/extensions/typescript-language-features/package.json @@ -865,6 +865,38 @@ "description": "%typescript.preferences.importModuleSpecifierEnding%", "scope": "resource" }, + "javascript.preferences.jsxAttributeCompletionStyle": { + "type": "string", + "enum": [ + "auto", + "braces", + "none" + ], + "markdownEnumDescriptions": [ + "%typescript.preferences.jsxAttributeCompletionStyle.auto%", + "%typescript.preferences.jsxAttributeCompletionStyle.braces%", + "%typescript.preferences.jsxAttributeCompletionStyle.none%" + ], + "default": "auto", + "description": "%typescript.preferences.jsxAttributeCompletionStyle%", + "scope": "resource" + }, + "typescript.preferences.jsxAttributeCompletionStyle": { + "type": "string", + "enum": [ + "auto", + "braces", + "none" + ], + "markdownEnumDescriptions": [ + "%typescript.preferences.jsxAttributeCompletionStyle.auto%", + "%typescript.preferences.jsxAttributeCompletionStyle.braces%", + "%typescript.preferences.jsxAttributeCompletionStyle.none%" + ], + "default": "auto", + "description": "%typescript.preferences.jsxAttributeCompletionStyle%", + "scope": "resource" + }, "typescript.preferences.includePackageJsonAutoImports": { "type": "string", "enum": [ diff --git a/extensions/typescript-language-features/package.nls.json b/extensions/typescript-language-features/package.nls.json index 12d96660df0..f399ff9ca9a 100644 --- a/extensions/typescript-language-features/package.nls.json +++ b/extensions/typescript-language-features/package.nls.json @@ -124,6 +124,10 @@ "typescript.preferences.importModuleSpecifierEnding.minimal": "Shorten `./component/index.js` to `./component`.", "typescript.preferences.importModuleSpecifierEnding.index": "Shorten `./component/index.js` to `./component/index`.", "typescript.preferences.importModuleSpecifierEnding.js": "Do not shorten path endings; include the `.js` extension.", + "typescript.preferences.jsxAttributeCompletionStyle": "Preferred style for JSX attribute completions.", + "typescript.preferences.jsxAttributeCompletionStyle.auto": "Insert `={}` or `=""` after attribute names based on the prop type.", + "typescript.preferences.jsxAttributeCompletionStyle.braces": "Insert `={}` after attribute names.", + "typescript.preferences.jsxAttributeCompletionStyle.none": "Only insert attribute names.", "typescript.preferences.includePackageJsonAutoImports": "Enable/disable searching `package.json` dependencies for available auto imports.", "typescript.preferences.includePackageJsonAutoImports.auto": "Search dependencies based on estimated performance impact.", "typescript.preferences.includePackageJsonAutoImports.on": "Always search dependencies.", diff --git a/extensions/typescript-language-features/src/languageFeatures/fileConfigurationManager.ts b/extensions/typescript-language-features/src/languageFeatures/fileConfigurationManager.ts index b61d46c9927..3c16df0b49b 100644 --- a/extensions/typescript-language-features/src/languageFeatures/fileConfigurationManager.ts +++ b/extensions/typescript-language-features/src/languageFeatures/fileConfigurationManager.ts @@ -191,6 +191,8 @@ export default class FileConfigurationManager extends Disposable { quotePreference: this.getQuoteStylePreference(preferencesConfig), importModuleSpecifierPreference: getImportModuleSpecifierPreference(preferencesConfig), importModuleSpecifierEnding: getImportModuleSpecifierEndingPreference(preferencesConfig), + // @ts-expect-error until TS 4.5 protocol update + jsxAttributeCompletionStyle: getJsxAttributeCompletionStyle(preferencesConfig), allowTextChangesInNewFiles: document.uri.scheme === fileSchemes.file, providePrefixAndSuffixTextForRename: preferencesConfig.get('renameShorthandProperties', true) === false ? false : preferencesConfig.get('useAliasesForRenames', true), allowRenameOfImportPath: true, @@ -263,3 +265,11 @@ function getImportModuleSpecifierEndingPreference(config: vscode.WorkspaceConfig default: return 'auto'; } } + +function getJsxAttributeCompletionStyle(config: vscode.WorkspaceConfiguration) { + switch (config.get('jsxAttributeCompletionStyle')) { + case 'braces': return 'braces'; + case 'none': return 'none'; + default: return 'auto'; + } +}