diff --git a/extensions/typescript-language-features/package.json b/extensions/typescript-language-features/package.json index 3b9917c412cf1f5cd58db14efadce7651d0bfc06..275b072798df102fee08bb4a6a10e19e0b448d30 100644 --- a/extensions/typescript-language-features/package.json +++ b/extensions/typescript-language-features/package.json @@ -264,6 +264,22 @@ "description": "%format.placeOpenBraceOnNewLineForControlBlocks%", "scope": "resource" }, + "typescript.format.semicolons": { + "type": "string", + "default": "ignore", + "description": "%format.semicolons%", + "scope": "resource", + "enum": [ + "ignore", + "insert", + "remove" + ], + "enumDescriptions": [ + "%format.semicolons.ignore%", + "%format.semicolons.insert%", + "%format.semicolons.remove%" + ] + }, "javascript.validate.enable": { "type": "boolean", "default": true, @@ -360,6 +376,22 @@ "description": "%format.placeOpenBraceOnNewLineForControlBlocks%", "scope": "resource" }, + "javascript.format.semicolons": { + "type": "string", + "default": "ignore", + "description": "%format.semicolons%", + "scope": "resource", + "enum": [ + "ignore", + "insert", + "remove" + ], + "enumDescriptions": [ + "%format.semicolons.ignore%", + "%format.semicolons.insert%", + "%format.semicolons.remove%" + ] + }, "javascript.implicitProjectConfig.checkJs": { "type": "boolean", "default": false, diff --git a/extensions/typescript-language-features/package.nls.json b/extensions/typescript-language-features/package.nls.json index a83acf9c6f2c9121f5028f8a142541004e1220db..19bc05bb9a94d57f48bf143faf35377ef8cf97b8 100644 --- a/extensions/typescript-language-features/package.nls.json +++ b/extensions/typescript-language-features/package.nls.json @@ -28,6 +28,10 @@ "format.insertSpaceAfterTypeAssertion": "Defines space handling after type assertions in TypeScript. Requires using TypeScript 2.4 or newer in the workspace.", "format.placeOpenBraceOnNewLineForFunctions": "Defines whether an open brace is put onto a new line for functions or not.", "format.placeOpenBraceOnNewLineForControlBlocks": "Defines whether an open brace is put onto a new line for control blocks or not.", + "format.semicolons": "Defines handling of optional semicolons. Requires using TypeScript 3.7 or newer in the workspace.", + "format.semicolons.ignore": "Don’t insert or remove any semicolons.", + "format.semicolons.insert": "Insert semicolons at statement ends.", + "format.semicolons.remove": "Remove unnecessary semicolons.", "javascript.validate.enable": "Enable/disable JavaScript validation.", "goToProjectConfig.title": "Go to Project Configuration", "javascript.referencesCodeLens.enabled": "Enable/disable references CodeLens in JavaScript files.", @@ -70,4 +74,4 @@ "configuration.surveys.enabled": "Enabled/disable occasional surveys that help us improve VS Code's JavaScript and TypeScript support.", "configuration.suggest.completeJSDocs": "Enable/disable suggestion to complete JSDoc comments.", "typescript.preferences.renameShorthandProperties": "Enable/disable introducing aliases for object shorthand properties during renames. Requires using TypeScript 3.4 or newer in the workspace." -} \ No newline at end of file +} diff --git a/extensions/typescript-language-features/src/features/fileConfigurationManager.ts b/extensions/typescript-language-features/src/features/fileConfigurationManager.ts index 6d35cd1b92b8239d04d2e528fa6564679079a06f..2d0ac26869380ad81b01e793a11b8e0edf23c4b4 100644 --- a/extensions/typescript-language-features/src/features/fileConfigurationManager.ts +++ b/extensions/typescript-language-features/src/features/fileConfigurationManager.ts @@ -144,7 +144,9 @@ export default class FileConfigurationManager extends Disposable { isTypeScriptDocument(document) ? 'typescript.format' : 'javascript.format', document.uri); - return { + // `semicolons` added to `Proto.FormatCodeSettings` in TypeScript 3.7: + // remove intersection type after upgrading TypeScript. + const settings: Proto.FormatCodeSettings & { semicolons?: string } = { tabSize: options.tabSize, indentSize: options.tabSize, convertTabsToSpaces: options.insertSpaces, @@ -165,7 +167,10 @@ export default class FileConfigurationManager extends Disposable { insertSpaceAfterTypeAssertion: config.get('insertSpaceAfterTypeAssertion'), placeOpenBraceOnNewLineForFunctions: config.get('placeOpenBraceOnNewLineForFunctions'), placeOpenBraceOnNewLineForControlBlocks: config.get('placeOpenBraceOnNewLineForControlBlocks'), + semicolons: config.get('semicolons'), }; + + return settings; } private getPreferences(document: vscode.TextDocument): Proto.UserPreferences { @@ -201,4 +206,4 @@ function getImportModuleSpecifierPreference(config: vscode.WorkspaceConfiguratio case 'non-relative': return 'non-relative'; default: return undefined; } -} \ No newline at end of file +}