forked from typescript-eslint/typescript-eslint
-
Notifications
You must be signed in to change notification settings - Fork 1
/
createProjectService.ts
55 lines (50 loc) · 1.69 KB
/
createProjectService.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import * as tsserver from 'typescript/lib/tsserverlibrary';
const doNothing = (): void => {};
const createStubFileWatcher = (): tsserver.FileWatcher => ({
close: doNothing,
});
export function createProjectService(): tsserver.server.ProjectService {
// TODO: see getWatchProgramsForProjects
// We don't watch the disk, we just refer to these when ESLint calls us
// there's a whole separate update pass in maybeInvalidateProgram at the bottom of getWatchProgramsForProjects
// (this "goes nuclear on TypeScript")
const system: tsserver.server.ServerHost = {
...tsserver.sys,
clearImmediate,
clearTimeout,
setImmediate,
setTimeout,
watchDirectory: createStubFileWatcher,
watchFile: createStubFileWatcher,
};
const projectService = new tsserver.server.ProjectService({
host: system,
cancellationToken: { isCancellationRequested: (): boolean => false },
useSingleInferredProject: false,
useInferredProjectPerProjectRoot: false,
// TODO: https://github.com/microsoft/TypeScript/issues/53803
typingsInstaller: {
attach: (): void => {},
enqueueInstallTypingsRequest: (): void => {},
installPackage: (): Promise<never> => {
throw new Error('This should never be called.');
},
isKnownTypesPackageName: () => false,
onProjectClosed: (): void => {},
globalTypingsCacheLocation: '',
},
logger: {
close: doNothing,
endGroup: doNothing,
getLogFileName: () => undefined,
hasLevel: () => false,
info: doNothing,
loggingEnabled: () => false,
msg: doNothing,
perftrc: doNothing,
startGroup: doNothing,
},
session: undefined,
});
return projectService;
}