Skip to content

Commit c998d7a

Browse files
committed
export TypingsInstaller from tsserverlibrary
1 parent 79a414b commit c998d7a

File tree

7 files changed

+85
-3
lines changed

7 files changed

+85
-3
lines changed

src/jsTyping/jsTyping.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import {
3131
versionMajorMinor,
3232
} from "./_namespaces/ts";
3333

34-
/** @internal */
3534
export interface TypingResolutionHost {
3635
directoryExists(path: string): boolean;
3736
fileExists(fileName: string): boolean;

src/jsTyping/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ export interface EndInstallTypes extends InstallTypes {
9999
readonly installSuccess: boolean;
100100
}
101101

102-
/** @internal */
103102
export interface InstallTypingHost extends JsTyping.TypingResolutionHost {
104103
useCaseSensitiveFileNames: boolean;
105104
writeFile(path: string, content: string): void;

src/server/_namespaces/ts.server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* Generated file to emulate the ts.server namespace. */
22

33
export * from "../../jsTyping/_namespaces/ts.server";
4+
export * from "../../typingsInstallerCore/_namespaces/ts.server";
45
export * from "../types";
56
export * from "../utilitiesPublic";
67
export * from "../utilities";

src/server/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"references": [
99
{ "path": "../compiler" },
1010
{ "path": "../jsTyping" },
11+
{ "path": "../typingsInstallerCore" },
1112
{ "path": "../services" },
1213
{ "path": "../deprecatedCompat" }
1314
],

src/typingsInstallerCore/typingsInstaller.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ export function getNpmCommandForInstallation(npmPath: string, tsVersion: string,
107107
}
108108

109109
export type RequestCompletedAction = (success: boolean) => void;
110-
interface PendingRequest {
110+
111+
export interface PendingRequest {
111112
requestId: number;
112113
packageNames: string[];
113114
cwd: string;
@@ -146,6 +147,7 @@ export abstract class TypingsInstaller {
146147
private readonly knownCachesSet = new Set<string>();
147148
private readonly projectWatchers = new Map<string, ProjectWatchers>();
148149
private safeList: JsTyping.SafeList | undefined;
150+
/** @internal */
149151
readonly pendingRunRequests: PendingRequest[] = [];
150152
private readonly toCanonicalFileName: GetCanonicalFileName;
151153
private readonly globalCachePackageJsonPath: string;

tests/baselines/reference/api/tsserverlibrary.d.ts

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@ declare namespace ts {
7979
readonly kind: EventEndInstallTypes;
8080
readonly installSuccess: boolean;
8181
}
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+
}
8290
interface SetTypings extends ProjectResponse {
8391
readonly typeAcquisition: TypeAcquisition;
8492
readonly compilerOptions: CompilerOptions;
@@ -2965,6 +2973,54 @@ declare namespace ts {
29652973
bigintLiteral = 25
29662974
}
29672975
}
2976+
namespace typingsInstaller {
2977+
interface Log {
2978+
isEnabled(): boolean;
2979+
writeLine(text: string): void;
2980+
}
2981+
type RequestCompletedAction = (success: boolean) => void;
2982+
interface PendingRequest {
2983+
requestId: number;
2984+
packageNames: string[];
2985+
cwd: string;
2986+
onRequestCompleted: RequestCompletedAction;
2987+
}
2988+
abstract class TypingsInstaller {
2989+
protected readonly installTypingHost: InstallTypingHost;
2990+
private readonly globalCachePath;
2991+
private readonly safeListPath;
2992+
private readonly typesMapLocation;
2993+
private readonly throttleLimit;
2994+
protected readonly log: Log;
2995+
private readonly packageNameToTypingLocation;
2996+
private readonly missingTypingsSet;
2997+
private readonly knownCachesSet;
2998+
private readonly projectWatchers;
2999+
private safeList;
3000+
private readonly toCanonicalFileName;
3001+
private readonly globalCachePackageJsonPath;
3002+
private installRunCount;
3003+
private inFlightRequestCount;
3004+
abstract readonly typesRegistry: Map<string, MapLike<string>>;
3005+
constructor(installTypingHost: InstallTypingHost, globalCachePath: string, safeListPath: Path, typesMapLocation: Path, throttleLimit: number, log?: Log);
3006+
closeProject(req: CloseProject): void;
3007+
private closeWatchers;
3008+
install(req: DiscoverTypings): void;
3009+
private initializeSafeList;
3010+
private processCacheLocation;
3011+
private filterTypings;
3012+
protected ensurePackageDirectoryExists(directory: string): void;
3013+
private installTypings;
3014+
private ensureDirectoryExists;
3015+
private watchFiles;
3016+
private createSetTypings;
3017+
private installTypingsAsync;
3018+
private executeWithThrottling;
3019+
protected abstract installWorker(requestId: number, packageNames: string[], cwd: string, onRequestCompleted: RequestCompletedAction): void;
3020+
protected abstract sendResponse(response: SetTypings | InvalidateCachedTypings | BeginInstallTypes | EndInstallTypes): void;
3021+
protected readonly latestDistTag = "latest";
3022+
}
3023+
}
29683024
interface CompressedData {
29693025
length: number;
29703026
compressionKind: string;
@@ -9789,6 +9845,14 @@ declare namespace ts {
97899845
emit(writeFile?: WriteFileCallback, customTransformers?: CustomTransformers): EmitResult | BuildInvalidedProject<T> | undefined;
97909846
}
97919847
type InvalidatedProject<T extends BuilderProgram> = UpdateOutputFileStampsProject | BuildInvalidedProject<T> | UpdateBundleProject<T>;
9848+
namespace JsTyping {
9849+
interface TypingResolutionHost {
9850+
directoryExists(path: string): boolean;
9851+
fileExists(fileName: string): boolean;
9852+
readFile(path: string, encoding?: string): string | undefined;
9853+
readDirectory(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[] | undefined, depth?: number): string[];
9854+
}
9855+
}
97929856
function getDefaultFormatCodeSettings(newLineCharacter?: string): FormatCodeSettings;
97939857
/**
97949858
* Represents an immutable snapshot of a script at a specified time.Once acquired, the

tests/baselines/reference/api/typescript.d.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5846,6 +5846,14 @@ declare namespace ts {
58465846
emit(writeFile?: WriteFileCallback, customTransformers?: CustomTransformers): EmitResult | BuildInvalidedProject<T> | undefined;
58475847
}
58485848
type InvalidatedProject<T extends BuilderProgram> = UpdateOutputFileStampsProject | BuildInvalidedProject<T> | UpdateBundleProject<T>;
5849+
namespace JsTyping {
5850+
interface TypingResolutionHost {
5851+
directoryExists(path: string): boolean;
5852+
fileExists(fileName: string): boolean;
5853+
readFile(path: string, encoding?: string): string | undefined;
5854+
readDirectory(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[] | undefined, depth?: number): string[];
5855+
}
5856+
}
58495857
namespace server {
58505858
type ActionSet = "action::set";
58515859
type ActionInvalidate = "action::invalidate";
@@ -5911,6 +5919,14 @@ declare namespace ts {
59115919
readonly kind: EventEndInstallTypes;
59125920
readonly installSuccess: boolean;
59135921
}
5922+
interface InstallTypingHost extends JsTyping.TypingResolutionHost {
5923+
useCaseSensitiveFileNames: boolean;
5924+
writeFile(path: string, content: string): void;
5925+
createDirectory(path: string): void;
5926+
getCurrentDirectory?(): string;
5927+
watchFile?(path: string, callback: FileWatcherCallback, pollingInterval?: number, options?: WatchOptions): FileWatcher;
5928+
watchDirectory?(path: string, callback: DirectoryWatcherCallback, recursive?: boolean, options?: WatchOptions): FileWatcher;
5929+
}
59145930
interface SetTypings extends ProjectResponse {
59155931
readonly typeAcquisition: TypeAcquisition;
59165932
readonly compilerOptions: CompilerOptions;

0 commit comments

Comments
 (0)