typescript-language-server 4.1.0 → 4.1.2
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 +15 -0
- package/lib/cli.mjs +35 -8
- package/lib/cli.mjs.map +1 -1
- package/package.json +13 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
All notable changes to this project will be documented in this file.
|
|
3
3
|
|
|
4
|
+
## [4.1.2](https://github.com/typescript-language-server/typescript-language-server/compare/v4.1.1...v4.1.2) (2023-11-14)
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
* avoid triggering unhandled exception when tsserver crashes ([#805](https://github.com/typescript-language-server/typescript-language-server/issues/805)) ([d537b08](https://github.com/typescript-language-server/typescript-language-server/commit/d537b08597d3d1b4e5b78e0e39bf0ba22f9a9dd1))
|
|
10
|
+
* revert to `Node` value for `moduleResolution` in implicit config ([#804](https://github.com/typescript-language-server/typescript-language-server/issues/804)) ([97c1794](https://github.com/typescript-language-server/typescript-language-server/commit/97c1794be311a2b327f07801119c76d616802ab5))
|
|
11
|
+
|
|
12
|
+
## [4.1.1](https://github.com/typescript-language-server/typescript-language-server/compare/v4.1.0...v4.1.1) (2023-11-13)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* try to infer languageId from extension when invalid provided ([#799](https://github.com/typescript-language-server/typescript-language-server/issues/799)) ([994186e](https://github.com/typescript-language-server/typescript-language-server/commit/994186e629494545f855d0859f5a058529e64c95))
|
|
18
|
+
|
|
4
19
|
## [4.1.0](https://github.com/typescript-language-server/typescript-language-server/compare/v4.0.0...v4.1.0) (2023-11-08)
|
|
5
20
|
|
|
6
21
|
|
package/lib/cli.mjs
CHANGED
|
@@ -25,7 +25,7 @@ import require$$0$3 from 'url';
|
|
|
25
25
|
|
|
26
26
|
import * as path$e from 'node:path';
|
|
27
27
|
|
|
28
|
-
import path__default, { resolve as resolve$1 } from 'node:path';
|
|
28
|
+
import path__default, { extname, resolve as resolve$1 } from 'node:path';
|
|
29
29
|
|
|
30
30
|
import require$$0$5 from 'constants';
|
|
31
31
|
|
|
@@ -14530,7 +14530,6 @@ var ModuleResolutionKind;
|
|
|
14530
14530
|
(function(ModuleResolutionKind) {
|
|
14531
14531
|
ModuleResolutionKind['Classic'] = 'Classic';
|
|
14532
14532
|
ModuleResolutionKind['Node'] = 'Node';
|
|
14533
|
-
ModuleResolutionKind['Bundler'] = 'Bundler';
|
|
14534
14533
|
})(ModuleResolutionKind || (ModuleResolutionKind = {}));
|
|
14535
14534
|
|
|
14536
14535
|
var SemicolonPreference;
|
|
@@ -17409,6 +17408,24 @@ function mode2ScriptKind(mode) {
|
|
|
17409
17408
|
return undefined;
|
|
17410
17409
|
}
|
|
17411
17410
|
|
|
17411
|
+
function getModeFromFileUri(uri) {
|
|
17412
|
+
const extension = extname(uri).toUpperCase();
|
|
17413
|
+
switch (extension) {
|
|
17414
|
+
case '.TS':
|
|
17415
|
+
return typescript;
|
|
17416
|
+
|
|
17417
|
+
case '.TSX':
|
|
17418
|
+
return typescriptreact;
|
|
17419
|
+
|
|
17420
|
+
case '.JS':
|
|
17421
|
+
return javascript;
|
|
17422
|
+
|
|
17423
|
+
case '.JSX':
|
|
17424
|
+
return javascriptreact;
|
|
17425
|
+
}
|
|
17426
|
+
return undefined;
|
|
17427
|
+
}
|
|
17428
|
+
|
|
17412
17429
|
class PendingDiagnostics extends ResourceMap {
|
|
17413
17430
|
getOrderedFileSet() {
|
|
17414
17431
|
const orderedResources = Array.from(this.entries()).sort(((a, b) => a.value - b.value)).map((entry => entry.resource));
|
|
@@ -17542,12 +17559,13 @@ class LspDocument {
|
|
|
17542
17559
|
}
|
|
17543
17560
|
|
|
17544
17561
|
class LspDocuments {
|
|
17545
|
-
constructor(client, onCaseInsensitiveFileSystem) {
|
|
17562
|
+
constructor(client, lspClient, onCaseInsensitiveFileSystem) {
|
|
17546
17563
|
this._validateJavaScript = true;
|
|
17547
17564
|
this._validateTypeScript = true;
|
|
17548
17565
|
this._files = [];
|
|
17549
17566
|
this.documents = new Map;
|
|
17550
17567
|
this.client = client;
|
|
17568
|
+
this.lspClient = lspClient;
|
|
17551
17569
|
this.modeIds = new Set(jsTsLanguageModes);
|
|
17552
17570
|
const pathNormalizer = path => this.client.toTsFilePath(path.toString());
|
|
17553
17571
|
this.pendingDiagnostics = new PendingDiagnostics(pathNormalizer, {
|
|
@@ -17574,7 +17592,16 @@ class LspDocuments {
|
|
|
17574
17592
|
}
|
|
17575
17593
|
openTextDocument(textDocument) {
|
|
17576
17594
|
if (!this.modeIds.has(textDocument.languageId)) {
|
|
17577
|
-
|
|
17595
|
+
const detectedLanguageId = getModeFromFileUri(textDocument.uri);
|
|
17596
|
+
if (detectedLanguageId) {
|
|
17597
|
+
this.lspClient.logMessage({
|
|
17598
|
+
type: main$3.MessageType.Warning,
|
|
17599
|
+
message: `Invalid langaugeId "${textDocument.languageId}" provided for uri "${textDocument.uri}". Correcting to "${detectedLanguageId}"`
|
|
17600
|
+
});
|
|
17601
|
+
textDocument.languageId = detectedLanguageId;
|
|
17602
|
+
} else {
|
|
17603
|
+
return false;
|
|
17604
|
+
}
|
|
17578
17605
|
}
|
|
17579
17606
|
const resource = textDocument.uri;
|
|
17580
17607
|
const filepath = this.client.toTsFilePath(resource);
|
|
@@ -19024,7 +19051,7 @@ class TsClient {
|
|
|
19024
19051
|
this.serverState = ServerState.None;
|
|
19025
19052
|
this.workspaceFolders = [];
|
|
19026
19053
|
this.useSyntaxServer = 2;
|
|
19027
|
-
this.documents = new LspDocuments(this, onCaseInsensitiveFileSystem);
|
|
19054
|
+
this.documents = new LspDocuments(this, lspClient, onCaseInsensitiveFileSystem);
|
|
19028
19055
|
this.logger = new PrefixingLogger(logger, '[tsclient]');
|
|
19029
19056
|
this.tsserverLogger = new PrefixingLogger(this.logger, '[tsserver]');
|
|
19030
19057
|
this.lspClient = lspClient;
|
|
@@ -19222,7 +19249,7 @@ class TsClient {
|
|
|
19222
19249
|
expectsResult: true,
|
|
19223
19250
|
...config
|
|
19224
19251
|
});
|
|
19225
|
-
executions[0].finally((() => {
|
|
19252
|
+
executions[0].catch((() => {})).finally((() => {
|
|
19226
19253
|
runningServerState.toCancelOnResourceChange.delete(inFlight);
|
|
19227
19254
|
source.dispose();
|
|
19228
19255
|
}));
|
|
@@ -21073,7 +21100,7 @@ function equals(one, other) {
|
|
|
21073
21100
|
function getInferredProjectCompilerOptions(version, workspaceConfig) {
|
|
21074
21101
|
const projectConfig = {
|
|
21075
21102
|
module: ModuleKind.ESNext,
|
|
21076
|
-
moduleResolution:
|
|
21103
|
+
moduleResolution: ModuleResolutionKind.Node,
|
|
21077
21104
|
target: ScriptTarget.ES2022,
|
|
21078
21105
|
jsx: JsxEmit.React
|
|
21079
21106
|
};
|
|
@@ -22615,7 +22642,7 @@ class LspServer {
|
|
|
22615
22642
|
throw new Error(`Can't open already open document: ${params.textDocument.uri}`);
|
|
22616
22643
|
}
|
|
22617
22644
|
if (!this.tsClient.openTextDocument(params.textDocument)) {
|
|
22618
|
-
throw new Error(`Cannot open document '${params.textDocument.uri}'.`);
|
|
22645
|
+
throw new Error(`Cannot open document '${params.textDocument.uri}' (languageId: ${params.textDocument.languageId}).`);
|
|
22619
22646
|
}
|
|
22620
22647
|
}
|
|
22621
22648
|
didCloseTextDocument(params) {
|