@@ -79,13 +79,70 @@ declare namespace ts {
79
79
readonly kind: EventEndInstallTypes;
80
80
readonly installSuccess: boolean;
81
81
}
82
+ interface InstallTypingHost extends JsTyping.TypingResolutionHost {
83
+ useCaseSensitiveFileNames: boolean;
84
+ writeFile(path: string, content: string): void;
85
+ createDirectory(path: string): void;
86
+ getCurrentDirectory?(): string;
87
+ watchFile?(path: string, callback: FileWatcherCallback, pollingInterval?: number, options?: WatchOptions): FileWatcher;
88
+ watchDirectory?(path: string, callback: DirectoryWatcherCallback, recursive?: boolean, options?: WatchOptions): FileWatcher;
89
+ }
82
90
interface SetTypings extends ProjectResponse {
83
91
readonly typeAcquisition: TypeAcquisition;
84
92
readonly compilerOptions: CompilerOptions;
85
93
readonly typings: string[];
86
94
readonly unresolvedImports: SortedReadonlyArray<string>;
87
95
readonly kind: ActionSet;
88
96
}
97
+ namespace typingsInstaller {
98
+ interface Log {
99
+ isEnabled(): boolean;
100
+ writeLine(text: string): void;
101
+ }
102
+ type RequestCompletedAction = (success: boolean) => void;
103
+ interface PendingRequest {
104
+ requestId: number;
105
+ packageNames: string[];
106
+ cwd: string;
107
+ onRequestCompleted: RequestCompletedAction;
108
+ }
109
+ abstract class TypingsInstaller {
110
+ protected readonly installTypingHost: InstallTypingHost;
111
+ private readonly globalCachePath;
112
+ private readonly safeListPath;
113
+ private readonly typesMapLocation;
114
+ private readonly throttleLimit;
115
+ protected readonly log: Log;
116
+ private readonly packageNameToTypingLocation;
117
+ private readonly missingTypingsSet;
118
+ private readonly knownCachesSet;
119
+ private readonly projectWatchers;
120
+ private safeList;
121
+ readonly pendingRunRequests: PendingRequest[];
122
+ private readonly toCanonicalFileName;
123
+ private readonly globalCachePackageJsonPath;
124
+ private installRunCount;
125
+ private inFlightRequestCount;
126
+ abstract readonly typesRegistry: Map<string, MapLike<string>>;
127
+ constructor(installTypingHost: InstallTypingHost, globalCachePath: string, safeListPath: Path, typesMapLocation: Path, throttleLimit: number, log?: Log);
128
+ closeProject(req: CloseProject): void;
129
+ private closeWatchers;
130
+ install(req: DiscoverTypings): void;
131
+ private initializeSafeList;
132
+ private processCacheLocation;
133
+ private filterTypings;
134
+ protected ensurePackageDirectoryExists(directory: string): void;
135
+ private installTypings;
136
+ private ensureDirectoryExists;
137
+ private watchFiles;
138
+ private createSetTypings;
139
+ private installTypingsAsync;
140
+ private executeWithThrottling;
141
+ protected abstract installWorker(requestId: number, packageNames: string[], cwd: string, onRequestCompleted: RequestCompletedAction): void;
142
+ protected abstract sendResponse(response: SetTypings | InvalidateCachedTypings | BeginInstallTypes | EndInstallTypes): void;
143
+ protected readonly latestDistTag = "latest";
144
+ }
145
+ }
89
146
namespace protocol {
90
147
enum CommandTypes {
91
148
JsxClosingTag = "jsxClosingTag",
@@ -9789,6 +9846,14 @@ declare namespace ts {
9789
9846
emit(writeFile?: WriteFileCallback, customTransformers?: CustomTransformers): EmitResult | BuildInvalidedProject<T> | undefined;
9790
9847
}
9791
9848
type InvalidatedProject<T extends BuilderProgram> = UpdateOutputFileStampsProject | BuildInvalidedProject<T> | UpdateBundleProject<T>;
9849
+ namespace JsTyping {
9850
+ interface TypingResolutionHost {
9851
+ directoryExists(path: string): boolean;
9852
+ fileExists(fileName: string): boolean;
9853
+ readFile(path: string, encoding?: string): string | undefined;
9854
+ readDirectory(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[] | undefined, depth?: number): string[];
9855
+ }
9856
+ }
9792
9857
function getDefaultFormatCodeSettings(newLineCharacter?: string): FormatCodeSettings;
9793
9858
/**
9794
9859
* Represents an immutable snapshot of a script at a specified time.Once acquired, the
0 commit comments