typescript-language-server 4.4.0 → 4.4.1

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
+ ## [4.4.1](https://github.com/typescript-language-server/typescript-language-server/compare/v4.4.0...v4.4.1) (2025-09-12)
5
+
6
+
7
+ ### Bug Fixes
8
+
9
+ * align completions code with upstream ([#992](https://github.com/typescript-language-server/typescript-language-server/issues/992)) ([f0eb0f5](https://github.com/typescript-language-server/typescript-language-server/commit/f0eb0f5abb981cbf496d5fc9e2b2e49150437c12))
10
+ * don't filter out 'warning' TS completion kinds ([ab388a0](https://github.com/typescript-language-server/typescript-language-server/commit/ab388a010cbe8353af6c17964e9e2567fa73cce0))
11
+
4
12
  ## [4.4.0](https://github.com/typescript-language-server/typescript-language-server/compare/v4.3.4...v4.4.0) (2025-08-05)
5
13
 
6
14
 
package/README.md CHANGED
@@ -4,14 +4,9 @@
4
4
 
5
5
  # TypeScript Language Server
6
6
 
7
- [Language Server Protocol](https://github.com/Microsoft/language-server-protocol) implementation for TypeScript wrapping `tsserver`.
8
-
9
- Originally based on concepts and ideas from https://github.com/prabirshrestha/typescript-language-server and maintained by [TypeFox](https://typefox.io). The core logic for interacting with `tsserver` is nowadays mostly based on the code of the `TypeScript Language Features` VSCode bundled extension maintained in https://github.com/microsoft/vscode.
10
-
11
- Maintained by a [community of contributors](https://github.com/typescript-language-server/typescript-language-server/graphs/contributors) like you.
12
-
13
7
  <!-- MarkdownTOC -->
14
8
 
9
+ - [What is it, exactly?](#what-is-it-exactly)
15
10
  - [Installing](#installing)
16
11
  - [Running the language server](#running-the-language-server)
17
12
  - [CLI Options](#cli-options)
@@ -38,6 +33,16 @@ Maintained by a [community of contributors](https://github.com/typescript-langua
38
33
 
39
34
  <!-- /MarkdownTOC -->
40
35
 
36
+ ## What is it, exactly?
37
+
38
+ The [TypeScript](https://github.com/microsoft/TypeScript) project/package includes a `tsserver` component which provides a custom API that can be used for gathering various intelligence about a typescript/javascript project. The [VSCode](https://github.com/microsoft/vscode) team has built a project called `Typescript Language Features` (and bundled it as an internal extension in VSCode) that provides code intelligence for your javascript and typescript projects by utilizing that `tsserver` API. Since that extension doesn't use the standardized [Language Server Protocol](https://microsoft.github.io/language-server-protocol/) to communicate with the editor, other editors that implement LSP can't directly utilize it. Here is where the `TypeScript Language Server` project comes in with the aim to provide a thin LSP interface on top of that extension's code base for the benefit of all other editors that implement the LSP protocol.
39
+
40
+ Originally based on concepts and ideas from https://github.com/prabirshrestha/typescript-language-server and maintained by [TypeFox](https://typefox.io). Currently maintained by a [community of contributors](https://github.com/typescript-language-server/typescript-language-server/graphs/contributors) like you.
41
+
42
+ This project is not directly associated with Microsoft and is not used in their [VSCode](https://github.com/microsoft/vscode) editor. If you have an issue with VSCode functionality, report it in their repository instead.
43
+
44
+ Currently Microsoft is working on [TypeScript 7](https://github.com/microsoft/typescript-go) written natively in the go language that will include the LSP implementation and will hopefully supersede this project.
45
+
41
46
  ## Installing
42
47
 
43
48
  ```sh
package/lib/cli.mjs CHANGED
@@ -14717,6 +14717,8 @@ KindModifiers.optional = 'optional';
14717
14717
 
14718
14718
  KindModifiers.deprecated = 'deprecated';
14719
14719
 
14720
+ KindModifiers.color = 'color';
14721
+
14720
14722
  KindModifiers.dtsFile = '.d.ts';
14721
14723
 
14722
14724
  KindModifiers.tsFile = '.ts';
@@ -19919,13 +19921,10 @@ class CompletionDataCache {
19919
19921
  }
19920
19922
  }
19921
19923
 
19922
- function asCompletionItems(entries, completionDataCache, file, position, document, filePathConverter, options, features, completionContext) {
19924
+ function asCompletionItems(entries, completionDataCache, file, position, document, filePathConverter, options, features, completionContext, defaultCommitCharacters) {
19923
19925
  const completions = [];
19924
19926
  for (const entry of entries) {
19925
- if (entry.kind === ScriptElementKind.warning) {
19926
- continue;
19927
- }
19928
- const completion = asCompletionItem(entry, completionDataCache, file, position, document, filePathConverter, options, features, completionContext);
19927
+ const completion = asCompletionItem(entry, completionDataCache, file, position, document, filePathConverter, options, features, completionContext, defaultCommitCharacters);
19929
19928
  if (!completion) {
19930
19929
  continue;
19931
19930
  }
@@ -19934,7 +19933,7 @@ function asCompletionItems(entries, completionDataCache, file, position, documen
19934
19933
  return completions;
19935
19934
  }
19936
19935
 
19937
- function asCompletionItem(entry, completionDataCache, file, position, document, filePathConverter, options, features, completionContext) {
19936
+ function asCompletionItem(entry, completionDataCache, file, position, document, filePathConverter, options, features, completionContext, defaultCommitCharacters) {
19938
19937
  const cacheId = completionDataCache.add({
19939
19938
  file: file,
19940
19939
  line: position.line + 1,
@@ -19946,7 +19945,7 @@ function asCompletionItem(entry, completionDataCache, file, position, document,
19946
19945
  } : entry.name ]
19947
19946
  });
19948
19947
  const item = {
19949
- label: entry.name,
19948
+ label: entry.name || (entry.insertText ?? ''),
19950
19949
  kind: asCompletionItemKind(entry.kind),
19951
19950
  sortText: entry.sortText,
19952
19951
  preselect: entry.isRecommended,
@@ -19954,15 +19953,15 @@ function asCompletionItem(entry, completionDataCache, file, position, document,
19954
19953
  cacheId: cacheId
19955
19954
  }
19956
19955
  };
19956
+ if (entry.source && entry.hasAction) {
19957
+ item.sortText = `￿${entry.sortText}`;
19958
+ }
19957
19959
  if (features.completionCommitCharactersSupport) {
19958
- item.commitCharacters = asCommitCharacters(entry.kind);
19960
+ item.commitCharacters = asCommitCharacters(completionContext, entry, defaultCommitCharacters);
19959
19961
  }
19960
19962
  if (features.completionLabelDetails) {
19961
19963
  item.labelDetails = entry.labelDetails;
19962
19964
  }
19963
- if (entry.source && entry.hasAction) {
19964
- item.sortText = `￿${entry.sortText}`;
19965
- }
19966
19965
  const {isSnippet: isSnippet, replacementSpan: replacementSpan, sourceDisplay: sourceDisplay} = entry;
19967
19966
  if (isSnippet && !features.completionSnippets) {
19968
19967
  return null;
@@ -20012,6 +20011,9 @@ function asCompletionItem(entry, completionDataCache, file, position, document,
20012
20011
  if (kindModifiers.has(KindModifiers.deprecated)) {
20013
20012
  item.tags = [ mainExports$2.CompletionItemTag.Deprecated ];
20014
20013
  }
20014
+ if (kindModifiers.has(KindModifiers.color)) {
20015
+ item.kind = mainExports$2.CompletionItemKind.Color;
20016
+ }
20015
20017
  if (entry.kind === ScriptElementKind.scriptElement) {
20016
20018
  for (const extModifier of KindModifiers.fileExtensionKindModifiers) {
20017
20019
  if (kindModifiers.has(extModifier)) {
@@ -20138,34 +20140,23 @@ function asCompletionItemKind(kind) {
20138
20140
  return mainExports$2.CompletionItemKind.Property;
20139
20141
  }
20140
20142
 
20141
- function asCommitCharacters(kind) {
20142
- const commitCharacters = [];
20143
- switch (kind) {
20144
- case ScriptElementKind.memberGetAccessorElement:
20145
- case ScriptElementKind.memberSetAccessorElement:
20146
- case ScriptElementKind.constructSignatureElement:
20147
- case ScriptElementKind.callSignatureElement:
20148
- case ScriptElementKind.indexSignatureElement:
20149
- case ScriptElementKind.enumElement:
20150
- case ScriptElementKind.interfaceElement:
20151
- commitCharacters.push('.');
20152
- break;
20153
-
20154
- case ScriptElementKind.moduleElement:
20155
- case ScriptElementKind.alias:
20156
- case ScriptElementKind.constElement:
20157
- case ScriptElementKind.letElement:
20158
- case ScriptElementKind.variableElement:
20159
- case ScriptElementKind.localVariableElement:
20160
- case ScriptElementKind.memberVariableElement:
20161
- case ScriptElementKind.classElement:
20162
- case ScriptElementKind.functionElement:
20163
- case ScriptElementKind.memberFunctionElement:
20164
- commitCharacters.push('.', ',');
20143
+ function asCommitCharacters(context, entry, defaultCommitCharacters) {
20144
+ const kind = entry.kind;
20145
+ let commitCharacters = entry.commitCharacters ?? (defaultCommitCharacters ? Array.from(defaultCommitCharacters) : undefined);
20146
+ if (commitCharacters) {
20147
+ if (context.enableCallCompletions && !context.isNewIdentifierLocation && kind !== ScriptElementKind.warning && kind !== ScriptElementKind.string) {
20148
+ commitCharacters.push('(');
20149
+ }
20150
+ return commitCharacters;
20151
+ }
20152
+ if (kind === ScriptElementKind.warning || kind === ScriptElementKind.string) {
20153
+ return undefined;
20154
+ }
20155
+ commitCharacters = [ '.', ',', ';' ];
20156
+ if (context.enableCallCompletions) {
20165
20157
  commitCharacters.push('(');
20166
- break;
20167
20158
  }
20168
- return commitCharacters.length === 0 ? undefined : commitCharacters;
20159
+ return commitCharacters;
20169
20160
  }
20170
20161
 
20171
20162
  async function asResolvedCompletionItem(item, details, document, client, options, features) {
@@ -22626,7 +22617,8 @@ class LspServer {
22626
22617
  if (!result) {
22627
22618
  return mainExports$2.CompletionList.create();
22628
22619
  }
22629
- const {entries: entries, isIncomplete: isIncomplete, optionalReplacementSpan: optionalReplacementSpan, isMemberCompletion: isMemberCompletion} = result;
22620
+ const {entries: entries, isIncomplete: isIncomplete, optionalReplacementSpan: optionalReplacementSpan, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation} = result;
22621
+ const defaultCommitCharacters = Object.freeze(result.defaultCommitCharacters);
22630
22622
  const line = document.getLine(params.position.line);
22631
22623
  let dotAccessorContext;
22632
22624
  if (isMemberCompletion) {
@@ -22642,12 +22634,14 @@ class LspServer {
22642
22634
  }
22643
22635
  }
22644
22636
  const completionContext = {
22637
+ enableCallCompletions: !completionOptions.completeFunctionCalls,
22645
22638
  isMemberCompletion: isMemberCompletion,
22639
+ isNewIdentifierLocation: isNewIdentifierLocation,
22646
22640
  dotAccessorContext: dotAccessorContext,
22647
22641
  line: line,
22648
22642
  optionalReplacementRange: optionalReplacementSpan ? Range.fromTextSpan(optionalReplacementSpan) : undefined
22649
22643
  };
22650
- const completions = asCompletionItems(entries, this.completionDataCache, filepath, params.position, document, this.tsClient, completionOptions, this.features, completionContext);
22644
+ const completions = asCompletionItems(entries, this.completionDataCache, filepath, params.position, document, this.tsClient, completionOptions, this.features, completionContext, defaultCommitCharacters);
22651
22645
  return mainExports$2.CompletionList.create(completions, isIncomplete);
22652
22646
  }
22653
22647
  async completionResolve(item, token) {