• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1import {
2    ActionInvalidate, ActionPackageInstalled, ActionSet, EventBeginInstallTypes, EventEndInstallTypes,
3    EventInitializationFailed, EventTypesRegistry,
4} from "./_namespaces/ts.server";
5import {
6    CompilerOptions, DirectoryWatcherCallback, FileWatcher, FileWatcherCallback, JsTyping, MapLike, Path,
7    SortedReadonlyArray, TypeAcquisition, WatchOptions,
8} from "./_namespaces/ts";
9
10export interface TypingInstallerResponse {
11    readonly kind: ActionSet | ActionInvalidate | EventTypesRegistry | ActionPackageInstalled | EventBeginInstallTypes | EventEndInstallTypes | EventInitializationFailed;
12}
13
14export interface TypingInstallerRequestWithProjectName {
15    readonly projectName: string;
16}
17
18/** @internal */
19export type TypingInstallerRequestUnion = DiscoverTypings | CloseProject | TypesRegistryRequest | InstallPackageRequest;
20
21export interface DiscoverTypings extends TypingInstallerRequestWithProjectName {
22    readonly fileNames: string[];
23    readonly projectRootPath: Path;
24    readonly compilerOptions: CompilerOptions;
25    readonly watchOptions?: WatchOptions;
26    readonly typeAcquisition: TypeAcquisition;
27    readonly unresolvedImports: SortedReadonlyArray<string>;
28    readonly cachePath?: string;
29    readonly kind: "discover";
30}
31
32export interface CloseProject extends TypingInstallerRequestWithProjectName {
33    readonly kind: "closeProject";
34}
35
36export interface TypesRegistryRequest {
37    readonly kind: "typesRegistry";
38}
39
40export interface InstallPackageRequest extends TypingInstallerRequestWithProjectName {
41    readonly kind: "installPackage";
42    readonly fileName: Path;
43    readonly packageName: string;
44    readonly projectRootPath: Path;
45}
46
47/** @internal */
48export interface TypesRegistryResponse extends TypingInstallerResponse {
49    readonly kind: EventTypesRegistry;
50    readonly typesRegistry: MapLike<MapLike<string>>;
51}
52
53export interface PackageInstalledResponse extends ProjectResponse {
54    readonly kind: ActionPackageInstalled;
55    readonly success: boolean;
56    readonly message: string;
57}
58
59export interface InitializationFailedResponse extends TypingInstallerResponse {
60    readonly kind: EventInitializationFailed;
61    readonly message: string;
62    readonly stack?: string;
63}
64
65export interface ProjectResponse extends TypingInstallerResponse {
66    readonly projectName: string;
67}
68
69export interface InvalidateCachedTypings extends ProjectResponse {
70    readonly kind: ActionInvalidate;
71}
72
73export interface InstallTypes extends ProjectResponse {
74    readonly kind: EventBeginInstallTypes | EventEndInstallTypes;
75    readonly eventId: number;
76    readonly typingsInstallerVersion: string;
77    readonly packagesToInstall: readonly string[];
78}
79
80export interface BeginInstallTypes extends InstallTypes {
81    readonly kind: EventBeginInstallTypes;
82}
83
84export interface EndInstallTypes extends InstallTypes {
85    readonly kind: EventEndInstallTypes;
86    readonly installSuccess: boolean;
87}
88
89/** @internal */
90export interface InstallTypingHost extends JsTyping.TypingResolutionHost {
91    useCaseSensitiveFileNames: boolean;
92    writeFile(path: string, content: string): void;
93    createDirectory(path: string): void;
94    getCurrentDirectory?(): string;
95    watchFile?(path: string, callback: FileWatcherCallback, pollingInterval?: number, options?: WatchOptions): FileWatcher;
96    watchDirectory?(path: string, callback: DirectoryWatcherCallback, recursive?: boolean, options?: WatchOptions): FileWatcher;
97}
98
99export interface SetTypings extends ProjectResponse {
100    readonly typeAcquisition: TypeAcquisition;
101    readonly compilerOptions: CompilerOptions;
102    readonly typings: string[];
103    readonly unresolvedImports: SortedReadonlyArray<string>;
104    readonly kind: ActionSet;
105}
106
107/** @internal */
108export type TypingInstallerResponseUnion = SetTypings | InvalidateCachedTypings | TypesRegistryResponse | PackageInstalledResponse | InstallTypes | InitializationFailedResponse;
109