typescript-language-server 5.0.1 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,14 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [5.1.0](https://github.com/typescript-language-server/typescript-language-server/compare/v5.0.1...v5.1.0) (2025-10-31)
5
+
6
+
7
+ ### Features
8
+
9
+ * request file-specific formatting options ([#1034](https://github.com/typescript-language-server/typescript-language-server/issues/1034)) ([de89dd3](https://github.com/typescript-language-server/typescript-language-server/commit/de89dd34b27d9dd65b9c3823ad2ddae06eb73c47))
10
+ * support passing "mode" to organize imports command ([#1036](https://github.com/typescript-language-server/typescript-language-server/issues/1036)) ([a7c24b8](https://github.com/typescript-language-server/typescript-language-server/commit/a7c24b85a4503f320aa78fb12ea6cb3f81186b28))
11
+
4
12
  ## [5.0.1](https://github.com/typescript-language-server/typescript-language-server/compare/v5.0.0...v5.0.1) (2025-10-07)
5
13
 
6
14
 
package/README.md CHANGED
@@ -23,6 +23,7 @@
23
23
  - [Code Lenses \(`textDocument/codeLens`\)](#code-lenses-textdocumentcodelens)
24
24
  - [Inlay hints \(`textDocument/inlayHint`\)](#inlay-hints-textdocumentinlayhint)
25
25
  - [TypeScript Version Notification](#typescript-version-notification)
26
+ - [Workspace Configuration request for formatting settings](#workspace-configuration-request-for-formatting-settings)
26
27
  - [Development](#development)
27
28
  - [Build](#build)
28
29
  - [Dev](#dev)
@@ -108,89 +109,112 @@ Most of the time, you'll execute commands with arguments retrieved from another
108
109
 
109
110
  #### Go to Source Definition
110
111
 
111
- - Request:
112
- ```ts
113
- {
114
- command: `_typescript.goToSourceDefinition`
115
- arguments: [
116
- lsp.DocumentUri, // String URI of the document
117
- lsp.Position, // Line and character position (zero-based)
118
- ]
119
- }
120
- ```
121
- - Response:
122
- ```ts
123
- lsp.Location[] | null
124
- ```
112
+ Request:
113
+
114
+ ```ts
115
+ {
116
+ command: '_typescript.goToSourceDefinition'
117
+ arguments: [
118
+ lsp.DocumentUri, // String URI of the document
119
+ lsp.Position, // Line and character position (zero-based)
120
+ ]
121
+ }
122
+ ```
123
+
124
+ Response:
125
+
126
+ ```ts
127
+ lsp.Location[] | null
128
+ ```
125
129
 
126
130
  (This command is supported from Typescript 4.7.)
127
131
 
128
132
  #### Apply Refactoring
129
133
 
130
- - Request:
131
- ```ts
132
- {
133
- command: `_typescript.applyRefactoring`
134
- arguments: [
135
- tsp.GetEditsForRefactorRequestArgs,
136
- ]
137
- }
138
- ```
139
- - Response:
140
- ```ts
141
- void
142
- ```
134
+ Request:
135
+
136
+ ```ts
137
+ {
138
+ command: '_typescript.applyRefactoring'
139
+ arguments: [
140
+ tsp.GetEditsForRefactorRequestArgs,
141
+ ]
142
+ }
143
+ ```
144
+
145
+ Response:
146
+
147
+ ```ts
148
+ void
149
+ ```
143
150
 
144
151
  #### Organize Imports
145
152
 
146
- - Request:
147
- ```ts
148
- {
149
- command: `_typescript.organizeImports`
150
- arguments: [
151
- // The "skipDestructiveCodeActions" argument is supported from Typescript 4.4+
152
- [string] | [string, { skipDestructiveCodeActions?: boolean }],
153
- ]
154
- }
155
- ```
156
- - Response:
157
- ```ts
158
- void
159
- ```
153
+ Request:
154
+
155
+ ```ts
156
+ {
157
+ command: '_typescript.organizeImports'
158
+ arguments: [
159
+ string, // file URI
160
+ // Optional options:
161
+ {
162
+ // @deprecated - use "mode". Supported from Typescript 4.4+.
163
+ skipDestructiveCodeActions?: boolean
164
+ // 'All' - organizes imports including destructive actions (removing unused imports)
165
+ // 'SortAndCombine' - Doesn't perform destructive actions.
166
+ // 'RemoveUnused' - Only removes unused imports.
167
+ mode?: 'All' | 'SortAndCombine' | 'RemoveUnused'
168
+ },
169
+ ]
170
+ }
171
+ ```
172
+
173
+ Response:
174
+
175
+ ```ts
176
+ void
177
+ ```
160
178
 
161
179
  #### Rename File
162
180
 
163
- - Request:
164
- ```ts
165
- {
166
- command: `_typescript.applyRenameFile`
167
- arguments: [
168
- { sourceUri: string; targetUri: string; },
169
- ]
170
- }
171
- ```
172
- - Response:
173
- ```ts
174
- void
175
- ```
181
+ Request:
182
+
183
+ ```ts
184
+ {
185
+ command: '_typescript.applyRenameFile'
186
+ arguments: [
187
+ { sourceUri: string; targetUri: string; },
188
+ ]
189
+ }
190
+ ```
191
+
192
+ Response:
193
+
194
+ ```ts
195
+ void
196
+ ```
176
197
 
177
198
  #### Send Tsserver Command
178
199
 
179
- - Request:
180
- ```ts
181
- {
182
- command: `typescript.tsserverRequest`
183
- arguments: [
184
- string, // command
185
- any, // command arguments in a format that the command expects
186
- ExecuteInfo, // configuration object used for the tsserver request (see below)
187
- ]
188
- }
189
- ```
190
- - Response:
191
- ```ts
192
- any
193
- ```
200
+ Request:
201
+
202
+ ```ts
203
+ {
204
+ command: 'typescript.tsserverRequest'
205
+ arguments: [
206
+ string, // command
207
+ any, // command arguments in a format that the command expects
208
+ ExecuteInfo, // configuration object used for the tsserver request (see below)
209
+ ]
210
+ }
211
+ ```
212
+
213
+ Response:
214
+
215
+ ```ts
216
+ any
217
+ ```
194
218
 
195
219
  The `ExecuteInfo` object is defined as follows:
196
220
 
@@ -205,17 +229,20 @@ type ExecuteInfo = {
205
229
 
206
230
  #### Configure plugin
207
231
 
208
- - Request:
209
- ```ts
210
- {
211
- command: `_typescript.configurePlugin`
212
- arguments: [pluginName: string, configuration: any]
213
- }
214
- ```
215
- - Response:
216
- ```ts
217
- void
218
- ```
232
+ Request:
233
+
234
+ ```ts
235
+ {
236
+ command: '_typescript.configurePlugin'
237
+ arguments: [pluginName: string, configuration: any]
238
+ }
239
+ ```
240
+
241
+ Response:
242
+
243
+ ```ts
244
+ void
245
+ ```
219
246
 
220
247
  ### Code Lenses (`textDocument/codeLens`)
221
248
 
@@ -275,6 +302,18 @@ The `$/typescriptVersion` notification params include two properties:
275
302
  - `version` - a semantic version (for example `4.8.4`)
276
303
  - `source` - a string specifying whether used TypeScript version comes from the local workspace (`workspace`), is explicitly specified through a `initializationOptions.tsserver.path` setting (`user-setting`) or was bundled with the server (`bundled`)
277
304
 
305
+
306
+ ### Workspace Configuration request for formatting settings
307
+
308
+ Server asks the client for file-specific configuration options (`tabSize` and `insertSpaces`) that are required by `tsserver` to properly format the file edits when for example using "Organize imports" or performing other file modifications. Those options have to be dynamically provided by the client/editor since the values can differ for each file. For this reason server sends a `workspace/configuration` request with `scopeUri` equal to file's URI and `section` equal to `formattingOptions`. The client is expected to return a configuration that includes the following properties:
309
+
310
+ ```js
311
+ {
312
+ "tabSize": number
313
+ "insertSpaces": boolean
314
+ }
315
+ ```
316
+
278
317
  ## Development
279
318
 
280
319
  ### Build