@teambit/ts-server 0.0.0-b5e3d30a4fe58fedfeafa7448ff4bad8debf4e32

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.
@@ -0,0 +1,112 @@
1
+ import { Logger } from '@teambit/logger';
2
+ import type ts from 'typescript/lib/tsserverlibrary';
3
+ import { CheckTypes } from '@teambit/watcher';
4
+ import type { Position } from 'vscode-languageserver-types';
5
+ import { Diagnostic } from './format-diagnostics';
6
+ export type TsserverClientOpts = {
7
+ verbose?: boolean;
8
+ tsServerPath?: string;
9
+ checkTypes?: CheckTypes;
10
+ printTypeErrors?: boolean;
11
+ aggregateDiagnosticData?: boolean;
12
+ };
13
+ export type DiagnosticData = {
14
+ file: string;
15
+ diagnostic: Diagnostic;
16
+ formatted: string;
17
+ };
18
+ export declare class TsserverClient {
19
+ /**
20
+ * absolute root path of the project.
21
+ */
22
+ private projectPath;
23
+ private logger;
24
+ private options;
25
+ /**
26
+ * provide files if you want to check types on init. (options.checkTypes should be enabled).
27
+ * paths should be absolute.
28
+ */
29
+ private files;
30
+ private tsServer;
31
+ lastDiagnostics: ts.server.protocol.DiagnosticEventBody[];
32
+ private serverRunning;
33
+ diagnosticData: DiagnosticData[];
34
+ constructor(
35
+ /**
36
+ * absolute root path of the project.
37
+ */
38
+ projectPath: string, logger: Logger, options?: TsserverClientOpts,
39
+ /**
40
+ * provide files if you want to check types on init. (options.checkTypes should be enabled).
41
+ * paths should be absolute.
42
+ */
43
+ files?: string[]);
44
+ /**
45
+ * start the ts-server and keep its process alive.
46
+ * this methods returns pretty fast. if checkTypes is enabled, it runs the process in the background and
47
+ * doesn't wait for it.
48
+ */
49
+ init(): Promise<void>;
50
+ private checkTypesIfNeeded;
51
+ private shouldCheckTypes;
52
+ /**
53
+ * if `bit watch` or `bit start` are running in the background, this method is triggered.
54
+ */
55
+ onFileChange(file: string): Promise<void>;
56
+ killTsServer(): void;
57
+ isServerRunning(): boolean;
58
+ /**
59
+ * get diagnostic of all files opened in the project.
60
+ * there is little to no value of getting diagnostic for a specific file, as
61
+ * changing a type in one file may cause errors in different files.
62
+ *
63
+ * the errors/diagnostic info are sent as events, see this.onTsserverEvent() for more info.
64
+ *
65
+ * the return value here just shows whether the request was succeeded, it doesn't have any info about whether errors
66
+ * were found or not.
67
+ */
68
+ getDiagnostic(files?: string[]): Promise<any>;
69
+ /**
70
+ * avoid using this method, it takes longer than `getDiagnostic()` and shows errors from paths outside the project
71
+ */
72
+ getDiagnosticAllProject(requestedByFile: string): Promise<any>;
73
+ /**
74
+ * @param file can be absolute or relative to this.projectRoot.
75
+ */
76
+ getQuickInfo(file: string, position: Position): Promise<ts.server.protocol.QuickInfoResponse | undefined>;
77
+ /**
78
+ * @param file can be absolute or relative to this.projectRoot.
79
+ */
80
+ getTypeDefinition(file: string, position: Position): Promise<ts.server.protocol.TypeDefinitionResponse | undefined>;
81
+ getDefinition(file: string, position: Position): Promise<ts.server.protocol.DefinitionResponse | undefined>;
82
+ /**
83
+ * @param file can be absolute or relative to this.projectRoot.
84
+ */
85
+ getReferences(file: string, position: Position): Promise<ts.server.protocol.ReferencesResponse | undefined>;
86
+ /**
87
+ * @param file can be absolute or relative to this.projectRoot.
88
+ */
89
+ getSignatureHelp(file: string, position: Position): Promise<ts.server.protocol.SignatureHelpResponse | undefined>;
90
+ private configure;
91
+ /**
92
+ * ask tsserver to open a file if it was not opened before.
93
+ * @param file absolute path of the file
94
+ */
95
+ openIfNeeded(file: string): Promise<void>;
96
+ private open;
97
+ close(file: string): Promise<void>;
98
+ /**
99
+ * since Bit is not an IDE, it doesn't have the information such as the exact line/offset of the changes.
100
+ * as a workaround, to tell tsserver what was changed, we pretend that the entire file was cleared and new text was
101
+ * added. this is the only way I could find to tell tsserver about the change. otherwise, tsserver keep assuming that
102
+ * the file content remained the same. (closing/re-opening the file doesn't help).
103
+ */
104
+ changed(file: string): Promise<void>;
105
+ protected onTsserverEvent(event: ts.server.protocol.Event): void;
106
+ private convertFileToAbsoluteIfNeeded;
107
+ private publishDiagnostic;
108
+ /**
109
+ * copied over from https://github.com/typescript-language-server/typescript-language-server/blob/master/src/lsp-server.ts
110
+ */
111
+ private findTsserverPath;
112
+ }
@@ -0,0 +1,382 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.TsserverClient = void 0;
7
+ function _fsExtra() {
8
+ const data = _interopRequireDefault(require("fs-extra"));
9
+ _fsExtra = function () {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ function _path() {
15
+ const data = _interopRequireDefault(require("path"));
16
+ _path = function () {
17
+ return data;
18
+ };
19
+ return data;
20
+ }
21
+ function _watcher() {
22
+ const data = require("@teambit/watcher");
23
+ _watcher = function () {
24
+ return data;
25
+ };
26
+ return data;
27
+ }
28
+ function _commandExists() {
29
+ const data = _interopRequireDefault(require("command-exists"));
30
+ _commandExists = function () {
31
+ return data;
32
+ };
33
+ return data;
34
+ }
35
+ function _modulesResolver() {
36
+ const data = require("./modules-resolver");
37
+ _modulesResolver = function () {
38
+ return data;
39
+ };
40
+ return data;
41
+ }
42
+ function _processBasedTsserver() {
43
+ const data = require("./process-based-tsserver");
44
+ _processBasedTsserver = function () {
45
+ return data;
46
+ };
47
+ return data;
48
+ }
49
+ function _tspCommandTypes() {
50
+ const data = require("./tsp-command-types");
51
+ _tspCommandTypes = function () {
52
+ return data;
53
+ };
54
+ return data;
55
+ }
56
+ function _utils() {
57
+ const data = require("./utils");
58
+ _utils = function () {
59
+ return data;
60
+ };
61
+ return data;
62
+ }
63
+ function _formatDiagnostics() {
64
+ const data = require("./format-diagnostics");
65
+ _formatDiagnostics = function () {
66
+ return data;
67
+ };
68
+ return data;
69
+ }
70
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
71
+ class TsserverClient {
72
+ lastDiagnostics = [];
73
+ serverRunning = false;
74
+ diagnosticData = [];
75
+ constructor(
76
+ /**
77
+ * absolute root path of the project.
78
+ */
79
+ projectPath, logger, options = {},
80
+ /**
81
+ * provide files if you want to check types on init. (options.checkTypes should be enabled).
82
+ * paths should be absolute.
83
+ */
84
+ files = []) {
85
+ this.projectPath = projectPath;
86
+ this.logger = logger;
87
+ this.options = options;
88
+ this.files = files;
89
+ }
90
+
91
+ /**
92
+ * start the ts-server and keep its process alive.
93
+ * this methods returns pretty fast. if checkTypes is enabled, it runs the process in the background and
94
+ * doesn't wait for it.
95
+ */
96
+ async init() {
97
+ try {
98
+ this.tsServer = new (_processBasedTsserver().ProcessBasedTsServer)({
99
+ logger: this.logger,
100
+ tsserverPath: this.findTsserverPath(),
101
+ logToConsole: this.options.verbose,
102
+ onEvent: this.onTsserverEvent.bind(this)
103
+ });
104
+ this.tsServer.start().then(() => {
105
+ this.serverRunning = true;
106
+ }).catch(err => {
107
+ this.logger.error('TsserverClient.init failed', err);
108
+ });
109
+ if (this.files.length) {
110
+ const openPromises = this.files.map(file => this.open(file));
111
+ await Promise.all(openPromises.map(promise => promise.catch(error => error)));
112
+ const failedFiles = openPromises.filter(promise => promise instanceof Error);
113
+ if (failedFiles.length > 0) {
114
+ this.logger.error('TsserverClient.init failed to open files:', failedFiles);
115
+ }
116
+ if (failedFiles.length > 0) {
117
+ this.logger.error('TsserverClient.init failed to open files:', failedFiles);
118
+ }
119
+ this.checkTypesIfNeeded();
120
+ }
121
+ this.logger.debug('TsserverClient.init completed');
122
+ } catch (err) {
123
+ this.logger.error('TsserverClient.init failed', err);
124
+ }
125
+ }
126
+ checkTypesIfNeeded(files = this.files) {
127
+ if (!this.shouldCheckTypes()) {
128
+ return;
129
+ }
130
+ const start = Date.now();
131
+ this.getDiagnostic(files).then(() => {
132
+ const end = Date.now() - start;
133
+ const msg = `completed type checking (${end / 1000} sec)`;
134
+ if (this.lastDiagnostics.length) {
135
+ this.logger.consoleFailure(`${msg}. found errors in ${this.lastDiagnostics.length} files.`);
136
+ } else {
137
+ this.logger.consoleSuccess(`${msg}. no errors were found.`);
138
+ }
139
+ }).catch(err => {
140
+ const msg = `failed getting the type errors from ts-server`;
141
+ this.logger.console(msg);
142
+ this.logger.error(msg, err);
143
+ });
144
+ }
145
+ shouldCheckTypes() {
146
+ // this also covers this.options.checkTypes !== CheckTypes.None.
147
+ return Boolean(this.options.checkTypes);
148
+ }
149
+
150
+ /**
151
+ * if `bit watch` or `bit start` are running in the background, this method is triggered.
152
+ */
153
+ async onFileChange(file) {
154
+ await this.changed(file);
155
+ const files = this.options.checkTypes === _watcher().CheckTypes.ChangedFile ? [file] : undefined;
156
+ this.checkTypesIfNeeded(files);
157
+ }
158
+ killTsServer() {
159
+ if (this.tsServer && this.serverRunning) {
160
+ this.tsServer.kill();
161
+ this.tsServer = null;
162
+ this.serverRunning = false;
163
+ }
164
+ }
165
+ isServerRunning() {
166
+ return this.serverRunning;
167
+ }
168
+
169
+ /**
170
+ * get diagnostic of all files opened in the project.
171
+ * there is little to no value of getting diagnostic for a specific file, as
172
+ * changing a type in one file may cause errors in different files.
173
+ *
174
+ * the errors/diagnostic info are sent as events, see this.onTsserverEvent() for more info.
175
+ *
176
+ * the return value here just shows whether the request was succeeded, it doesn't have any info about whether errors
177
+ * were found or not.
178
+ */
179
+ async getDiagnostic(files = this.files) {
180
+ this.lastDiagnostics = [];
181
+ return this.tsServer?.request(_tspCommandTypes().CommandTypes.Geterr, {
182
+ delay: 0,
183
+ files
184
+ });
185
+ }
186
+
187
+ /**
188
+ * avoid using this method, it takes longer than `getDiagnostic()` and shows errors from paths outside the project
189
+ */
190
+ async getDiagnosticAllProject(requestedByFile) {
191
+ return this.tsServer?.request(_tspCommandTypes().CommandTypes.GeterrForProject, {
192
+ file: requestedByFile,
193
+ delay: 0
194
+ });
195
+ }
196
+
197
+ /**
198
+ * @param file can be absolute or relative to this.projectRoot.
199
+ */
200
+ async getQuickInfo(file, position) {
201
+ const absFile = this.convertFileToAbsoluteIfNeeded(file);
202
+ await this.openIfNeeded(absFile);
203
+ return this.tsServer?.request(_tspCommandTypes().CommandTypes.Quickinfo, {
204
+ file: absFile,
205
+ line: position.line,
206
+ offset: position.character
207
+ });
208
+ }
209
+
210
+ /**
211
+ * @param file can be absolute or relative to this.projectRoot.
212
+ */
213
+ async getTypeDefinition(file, position) {
214
+ const absFile = this.convertFileToAbsoluteIfNeeded(file);
215
+ await this.openIfNeeded(absFile);
216
+ return this.tsServer?.request(_tspCommandTypes().CommandTypes.TypeDefinition, {
217
+ file: absFile,
218
+ line: position.line,
219
+ offset: position.character
220
+ });
221
+ }
222
+ async getDefinition(file, position) {
223
+ const absFile = this.convertFileToAbsoluteIfNeeded(file);
224
+ await this.openIfNeeded(absFile);
225
+ const response = await this.tsServer?.request(_tspCommandTypes().CommandTypes.Definition, {
226
+ file: absFile,
227
+ line: position.line,
228
+ offset: position.character
229
+ });
230
+ if (!response?.success) {
231
+ // TODO: we need a function to handle responses properly here for all.
232
+ this.logger.warn(`For file ${absFile} tsserver failed to request definition info`);
233
+ return response;
234
+ }
235
+ return response;
236
+ }
237
+
238
+ /**
239
+ * @param file can be absolute or relative to this.projectRoot.
240
+ */
241
+ async getReferences(file, position) {
242
+ const absFile = this.convertFileToAbsoluteIfNeeded(file);
243
+ await this.openIfNeeded(absFile);
244
+ return this.tsServer?.request(_tspCommandTypes().CommandTypes.References, {
245
+ file: absFile,
246
+ line: position.line,
247
+ offset: position.character
248
+ });
249
+ }
250
+
251
+ /**
252
+ * @param file can be absolute or relative to this.projectRoot.
253
+ */
254
+ async getSignatureHelp(file, position) {
255
+ const absFile = this.convertFileToAbsoluteIfNeeded(file);
256
+ await this.openIfNeeded(absFile);
257
+ return this.tsServer?.request(_tspCommandTypes().CommandTypes.SignatureHelp, {
258
+ file: absFile,
259
+ line: position.line,
260
+ offset: position.character
261
+ });
262
+ }
263
+ async configure(configureArgs = {}) {
264
+ return this.tsServer?.request(_tspCommandTypes().CommandTypes.Configure, configureArgs);
265
+ }
266
+
267
+ /**
268
+ * ask tsserver to open a file if it was not opened before.
269
+ * @param file absolute path of the file
270
+ */
271
+ async openIfNeeded(file) {
272
+ if (this.files.includes(file)) {
273
+ return;
274
+ }
275
+ await this.open(file);
276
+ this.files.push(file);
277
+ }
278
+ async open(file) {
279
+ return this.tsServer?.notify(_tspCommandTypes().CommandTypes.Open, {
280
+ file,
281
+ projectRootPath: this.projectPath
282
+ });
283
+ }
284
+ async close(file) {
285
+ await this.tsServer?.notify(_tspCommandTypes().CommandTypes.Close, {
286
+ file
287
+ });
288
+ this.files = this.files.filter(openFile => openFile !== file);
289
+ }
290
+
291
+ /**
292
+ * since Bit is not an IDE, it doesn't have the information such as the exact line/offset of the changes.
293
+ * as a workaround, to tell tsserver what was changed, we pretend that the entire file was cleared and new text was
294
+ * added. this is the only way I could find to tell tsserver about the change. otherwise, tsserver keep assuming that
295
+ * the file content remained the same. (closing/re-opening the file doesn't help).
296
+ */
297
+ async changed(file) {
298
+ // tell tsserver that all content was removed
299
+ await this.tsServer?.notify(_tspCommandTypes().CommandTypes.Change, {
300
+ file,
301
+ line: 1,
302
+ offset: 1,
303
+ endLine: 99999,
304
+ endOffset: 1,
305
+ insertString: ''
306
+ });
307
+ const content = await _fsExtra().default.readFile(file, 'utf-8');
308
+
309
+ // tell tsserver that all file content was added
310
+ await this.tsServer?.notify(_tspCommandTypes().CommandTypes.Change, {
311
+ file,
312
+ line: 1,
313
+ offset: 1,
314
+ endLine: 1,
315
+ endOffset: 1,
316
+ insertString: content
317
+ });
318
+ }
319
+ onTsserverEvent(event) {
320
+ switch (event.event) {
321
+ case _tspCommandTypes().EventName.semanticDiag:
322
+ case _tspCommandTypes().EventName.syntaxDiag:
323
+ this.publishDiagnostic(event);
324
+ break;
325
+ default:
326
+ this.logger.debug(`ignored TsServer event: ${event.event}`);
327
+ }
328
+ }
329
+ convertFileToAbsoluteIfNeeded(filepath) {
330
+ if (_path().default.isAbsolute(filepath)) {
331
+ return filepath;
332
+ }
333
+ return _path().default.join(this.projectPath, filepath);
334
+ }
335
+ publishDiagnostic(message) {
336
+ if (!message.body?.diagnostics.length || !this.options.printTypeErrors && !this.options.aggregateDiagnosticData) {
337
+ return;
338
+ }
339
+ this.lastDiagnostics.push(message.body);
340
+ const file = _path().default.relative(this.projectPath, message.body.file);
341
+ message.body.diagnostics.forEach(diag => {
342
+ const formatted = (0, _formatDiagnostics().formatDiagnostic)(diag, file);
343
+ if (this.options.printTypeErrors) {
344
+ this.logger.console(formatted);
345
+ }
346
+ if (this.options.aggregateDiagnosticData) {
347
+ this.diagnosticData.push({
348
+ file,
349
+ diagnostic: diag,
350
+ formatted
351
+ });
352
+ }
353
+ });
354
+ }
355
+
356
+ /**
357
+ * copied over from https://github.com/typescript-language-server/typescript-language-server/blob/master/src/lsp-server.ts
358
+ */
359
+ findTsserverPath() {
360
+ if (this.options.tsServerPath) {
361
+ return this.options.tsServerPath;
362
+ }
363
+ const tsServerPath = _path().default.join('typescript', 'lib', 'tsserver.js');
364
+
365
+ /**
366
+ * (1) find it in the bit directory
367
+ */
368
+ const bundled = (0, _modulesResolver().findPathToModule)(__dirname, tsServerPath);
369
+ if (bundled) {
370
+ return bundled;
371
+ }
372
+
373
+ // (2) use globally installed tsserver
374
+ if (_commandExists().default.sync((0, _utils().getTsserverExecutable)())) {
375
+ return (0, _utils().getTsserverExecutable)();
376
+ }
377
+ throw new Error(`Couldn't find '${(0, _utils().getTsserverExecutable)()}' executable or 'tsserver.js' module`);
378
+ }
379
+ }
380
+ exports.TsserverClient = TsserverClient;
381
+
382
+ //# sourceMappingURL=ts-server-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_fsExtra","data","_interopRequireDefault","require","_path","_watcher","_commandExists","_modulesResolver","_processBasedTsserver","_tspCommandTypes","_utils","_formatDiagnostics","e","__esModule","default","TsserverClient","lastDiagnostics","serverRunning","diagnosticData","constructor","projectPath","logger","options","files","init","tsServer","ProcessBasedTsServer","tsserverPath","findTsserverPath","logToConsole","verbose","onEvent","onTsserverEvent","bind","start","then","catch","err","error","length","openPromises","map","file","open","Promise","all","promise","failedFiles","filter","Error","checkTypesIfNeeded","debug","shouldCheckTypes","Date","now","getDiagnostic","end","msg","consoleFailure","consoleSuccess","console","Boolean","checkTypes","onFileChange","changed","CheckTypes","ChangedFile","undefined","killTsServer","kill","isServerRunning","request","CommandTypes","Geterr","delay","getDiagnosticAllProject","requestedByFile","GeterrForProject","getQuickInfo","position","absFile","convertFileToAbsoluteIfNeeded","openIfNeeded","Quickinfo","line","offset","character","getTypeDefinition","TypeDefinition","getDefinition","response","Definition","success","warn","getReferences","References","getSignatureHelp","SignatureHelp","configure","configureArgs","Configure","includes","push","notify","Open","projectRootPath","close","Close","openFile","Change","endLine","endOffset","insertString","content","fs","readFile","event","EventName","semanticDiag","syntaxDiag","publishDiagnostic","filepath","path","isAbsolute","join","message","body","diagnostics","printTypeErrors","aggregateDiagnosticData","relative","forEach","diag","formatted","formatDiagnostic","diagnostic","tsServerPath","bundled","findPathToModule","__dirname","commandExists","sync","getTsserverExecutable","exports"],"sources":["ts-server-client.ts"],"sourcesContent":["import fs from 'fs-extra';\nimport { Logger } from '@teambit/logger';\nimport path from 'path';\nimport type ts from 'typescript/lib/tsserverlibrary';\nimport { CheckTypes } from '@teambit/watcher';\nimport type { Position } from 'vscode-languageserver-types';\nimport commandExists from 'command-exists';\nimport { findPathToModule } from './modules-resolver';\nimport { ProcessBasedTsServer } from './process-based-tsserver';\nimport { CommandTypes, EventName } from './tsp-command-types';\nimport { getTsserverExecutable } from './utils';\nimport { formatDiagnostic, Diagnostic } from './format-diagnostics';\n\nexport type TsserverClientOpts = {\n verbose?: boolean; // print tsserver events to the console.\n tsServerPath?: string; // if not provided, it'll use findTsserverPath() strategies.\n checkTypes?: CheckTypes; // whether errors/warnings are monitored and printed to the console.\n printTypeErrors?: boolean; // whether print typescript errors to the console.\n aggregateDiagnosticData?: boolean; // whether to aggregate diagnostic data instead of printing them to the console.\n};\n\nexport type DiagnosticData = {\n file: string;\n diagnostic: Diagnostic;\n formatted: string;\n};\n\nexport class TsserverClient {\n private tsServer: ProcessBasedTsServer | null;\n public lastDiagnostics: ts.server.protocol.DiagnosticEventBody[] = [];\n private serverRunning = false;\n public diagnosticData: DiagnosticData[] = [];\n constructor(\n /**\n * absolute root path of the project.\n */\n private projectPath: string,\n private logger: Logger,\n private options: TsserverClientOpts = {},\n /**\n * provide files if you want to check types on init. (options.checkTypes should be enabled).\n * paths should be absolute.\n */\n private files: string[] = []\n ) {}\n\n /**\n * start the ts-server and keep its process alive.\n * this methods returns pretty fast. if checkTypes is enabled, it runs the process in the background and\n * doesn't wait for it.\n */\n async init(): Promise<void> {\n try {\n this.tsServer = new ProcessBasedTsServer({\n logger: this.logger,\n tsserverPath: this.findTsserverPath(),\n logToConsole: this.options.verbose,\n onEvent: this.onTsserverEvent.bind(this),\n });\n\n this.tsServer\n .start()\n .then(() => {\n this.serverRunning = true;\n })\n .catch((err) => {\n this.logger.error('TsserverClient.init failed', err);\n });\n\n if (this.files.length) {\n const openPromises = this.files.map((file) => this.open(file));\n await Promise.all(openPromises.map((promise) => promise.catch((error) => error)));\n const failedFiles = openPromises.filter((promise) => promise instanceof Error);\n if (failedFiles.length > 0) {\n this.logger.error('TsserverClient.init failed to open files:', failedFiles);\n }\n if (failedFiles.length > 0) {\n this.logger.error('TsserverClient.init failed to open files:', failedFiles);\n }\n this.checkTypesIfNeeded();\n }\n this.logger.debug('TsserverClient.init completed');\n } catch (err) {\n this.logger.error('TsserverClient.init failed', err);\n }\n }\n\n private checkTypesIfNeeded(files = this.files) {\n if (!this.shouldCheckTypes()) {\n return;\n }\n const start = Date.now();\n this.getDiagnostic(files)\n .then(() => {\n const end = Date.now() - start;\n const msg = `completed type checking (${end / 1000} sec)`;\n if (this.lastDiagnostics.length) {\n this.logger.consoleFailure(`${msg}. found errors in ${this.lastDiagnostics.length} files.`);\n } else {\n this.logger.consoleSuccess(`${msg}. no errors were found.`);\n }\n })\n .catch((err) => {\n const msg = `failed getting the type errors from ts-server`;\n this.logger.console(msg);\n this.logger.error(msg, err);\n });\n }\n\n private shouldCheckTypes() {\n // this also covers this.options.checkTypes !== CheckTypes.None.\n return Boolean(this.options.checkTypes);\n }\n\n /**\n * if `bit watch` or `bit start` are running in the background, this method is triggered.\n */\n async onFileChange(file: string) {\n await this.changed(file);\n const files = this.options.checkTypes === CheckTypes.ChangedFile ? [file] : undefined;\n this.checkTypesIfNeeded(files);\n }\n\n killTsServer() {\n if (this.tsServer && this.serverRunning) {\n this.tsServer.kill();\n this.tsServer = null;\n this.serverRunning = false;\n }\n }\n\n isServerRunning() {\n return this.serverRunning;\n }\n\n /**\n * get diagnostic of all files opened in the project.\n * there is little to no value of getting diagnostic for a specific file, as\n * changing a type in one file may cause errors in different files.\n *\n * the errors/diagnostic info are sent as events, see this.onTsserverEvent() for more info.\n *\n * the return value here just shows whether the request was succeeded, it doesn't have any info about whether errors\n * were found or not.\n */\n async getDiagnostic(files = this.files): Promise<any> {\n this.lastDiagnostics = [];\n return this.tsServer?.request(CommandTypes.Geterr, { delay: 0, files });\n }\n\n /**\n * avoid using this method, it takes longer than `getDiagnostic()` and shows errors from paths outside the project\n */\n async getDiagnosticAllProject(requestedByFile: string): Promise<any> {\n return this.tsServer?.request(CommandTypes.GeterrForProject, { file: requestedByFile, delay: 0 });\n }\n\n /**\n * @param file can be absolute or relative to this.projectRoot.\n */\n async getQuickInfo(file: string, position: Position): Promise<ts.server.protocol.QuickInfoResponse | undefined> {\n const absFile = this.convertFileToAbsoluteIfNeeded(file);\n await this.openIfNeeded(absFile);\n return this.tsServer?.request(CommandTypes.Quickinfo, {\n file: absFile,\n line: position.line,\n offset: position.character,\n });\n }\n\n /**\n * @param file can be absolute or relative to this.projectRoot.\n */\n async getTypeDefinition(\n file: string,\n position: Position\n ): Promise<ts.server.protocol.TypeDefinitionResponse | undefined> {\n const absFile = this.convertFileToAbsoluteIfNeeded(file);\n await this.openIfNeeded(absFile);\n return this.tsServer?.request(CommandTypes.TypeDefinition, {\n file: absFile,\n line: position.line,\n offset: position.character,\n });\n }\n\n async getDefinition(file: string, position: Position) {\n const absFile = this.convertFileToAbsoluteIfNeeded(file);\n await this.openIfNeeded(absFile);\n const response = await this.tsServer?.request(CommandTypes.Definition, {\n file: absFile,\n line: position.line,\n offset: position.character,\n });\n\n if (!response?.success) {\n // TODO: we need a function to handle responses properly here for all.\n this.logger.warn(`For file ${absFile} tsserver failed to request definition info`);\n return response;\n }\n\n return response;\n }\n\n /**\n * @param file can be absolute or relative to this.projectRoot.\n */\n async getReferences(file: string, position: Position): Promise<ts.server.protocol.ReferencesResponse | undefined> {\n const absFile = this.convertFileToAbsoluteIfNeeded(file);\n await this.openIfNeeded(absFile);\n return this.tsServer?.request(CommandTypes.References, {\n file: absFile,\n line: position.line,\n offset: position.character,\n });\n }\n\n /**\n * @param file can be absolute or relative to this.projectRoot.\n */\n async getSignatureHelp(\n file: string,\n position: Position\n ): Promise<ts.server.protocol.SignatureHelpResponse | undefined> {\n const absFile = this.convertFileToAbsoluteIfNeeded(file);\n await this.openIfNeeded(absFile);\n\n return this.tsServer?.request(CommandTypes.SignatureHelp, {\n file: absFile,\n line: position.line,\n offset: position.character,\n });\n }\n\n private async configure(\n configureArgs: ts.server.protocol.ConfigureRequestArguments = {}\n ): Promise<ts.server.protocol.ConfigureResponse | undefined> {\n return this.tsServer?.request(CommandTypes.Configure, configureArgs);\n }\n\n /**\n * ask tsserver to open a file if it was not opened before.\n * @param file absolute path of the file\n */\n async openIfNeeded(file: string) {\n if (this.files.includes(file)) {\n return;\n }\n await this.open(file);\n this.files.push(file);\n }\n\n private async open(file: string) {\n return this.tsServer?.notify(CommandTypes.Open, {\n file,\n projectRootPath: this.projectPath,\n });\n }\n\n async close(file: string) {\n await this.tsServer?.notify(CommandTypes.Close, {\n file,\n });\n this.files = this.files.filter((openFile) => openFile !== file);\n }\n\n /**\n * since Bit is not an IDE, it doesn't have the information such as the exact line/offset of the changes.\n * as a workaround, to tell tsserver what was changed, we pretend that the entire file was cleared and new text was\n * added. this is the only way I could find to tell tsserver about the change. otherwise, tsserver keep assuming that\n * the file content remained the same. (closing/re-opening the file doesn't help).\n */\n async changed(file: string) {\n // tell tsserver that all content was removed\n await this.tsServer?.notify(CommandTypes.Change, {\n file,\n line: 1,\n offset: 1,\n endLine: 99999,\n endOffset: 1,\n insertString: '',\n });\n\n const content = await fs.readFile(file, 'utf-8');\n\n // tell tsserver that all file content was added\n await this.tsServer?.notify(CommandTypes.Change, {\n file,\n line: 1,\n offset: 1,\n endLine: 1,\n endOffset: 1,\n insertString: content,\n });\n }\n\n protected onTsserverEvent(event: ts.server.protocol.Event): void {\n switch (event.event) {\n case EventName.semanticDiag:\n case EventName.syntaxDiag:\n this.publishDiagnostic(event as ts.server.protocol.DiagnosticEvent);\n break;\n default:\n this.logger.debug(`ignored TsServer event: ${event.event}`);\n }\n }\n\n private convertFileToAbsoluteIfNeeded(filepath: string): string {\n if (path.isAbsolute(filepath)) {\n return filepath;\n }\n return path.join(this.projectPath, filepath);\n }\n\n private publishDiagnostic(message: ts.server.protocol.DiagnosticEvent) {\n if (!message.body?.diagnostics.length || (!this.options.printTypeErrors && !this.options.aggregateDiagnosticData)) {\n return;\n }\n this.lastDiagnostics.push(message.body);\n const file = path.relative(this.projectPath, message.body.file);\n message.body.diagnostics.forEach((diag) => {\n const formatted = formatDiagnostic(diag, file);\n if (this.options.printTypeErrors) {\n this.logger.console(formatted);\n }\n if (this.options.aggregateDiagnosticData) {\n this.diagnosticData.push({\n file,\n diagnostic: diag,\n formatted,\n });\n }\n });\n }\n\n /**\n * copied over from https://github.com/typescript-language-server/typescript-language-server/blob/master/src/lsp-server.ts\n */\n private findTsserverPath(): string {\n if (this.options.tsServerPath) {\n return this.options.tsServerPath;\n }\n\n const tsServerPath = path.join('typescript', 'lib', 'tsserver.js');\n\n /**\n * (1) find it in the bit directory\n */\n const bundled = findPathToModule(__dirname, tsServerPath);\n\n if (bundled) {\n return bundled;\n }\n\n // (2) use globally installed tsserver\n if (commandExists.sync(getTsserverExecutable())) {\n return get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