UNPKG

9.92 kBTypeScriptView Raw
1import * as typescript from 'typescript';
2import { Chalk } from 'chalk';
3import * as logger from './logger';
4export interface ErrorInfo {
5 code: number;
6 severity: Severity;
7 content: string;
8 file: string;
9 line: number;
10 character: number;
11 context: string;
12}
13export declare type FileLocation = {
14 line: number;
15 character: number;
16};
17export interface WebpackError {
18 module?: any;
19 file?: string;
20 message: string;
21 location?: FileLocation;
22 loaderSource: string;
23}
24export interface WebpackModule {
25 resource: string;
26 errors: WebpackError[];
27 addWarning(warning: Error): void;
28 addError(error: WebpackError | Error): void;
29 getWarnings(): Iterable<Error> | undefined;
30 getErrors(): Iterable<WebpackError | Error> | undefined;
31 clearWarningsAndErrors(): void;
32 buildMeta: {
33 tsLoaderFileVersion: number;
34 tsLoaderDefinitionFileVersions: string[];
35 };
36}
37export declare type ResolveSync = (context: string | undefined, path: string, moduleName: string) => string;
38export declare type Action = () => void;
39export interface HostMayBeCacheable {
40 clearCache?: Action;
41}
42export interface CacheableHost extends HostMayBeCacheable {
43 fileExists: typescript.ModuleResolutionHost['fileExists'];
44 directoryExists: NonNullable<typescript.ModuleResolutionHost['directoryExists']>;
45 realpath?: typescript.ModuleResolutionHost['realpath'];
46}
47export interface ModuleResolutionHostMayBeCacheable extends typescript.ModuleResolutionHost, HostMayBeCacheable {
48 readFile(filePath: string, encoding?: string): string | undefined;
49 trace: NonNullable<typescript.ModuleResolutionHost['trace']>;
50 directoryExists: NonNullable<typescript.ModuleResolutionHost['directoryExists']>;
51 getCurrentDirectory: NonNullable<typescript.ModuleResolutionHost['getCurrentDirectory']>;
52 getDirectories: NonNullable<typescript.ModuleResolutionHost['getDirectories']>;
53 useCaseSensitiveFileNames: NonNullable<typescript.LanguageServiceHost['useCaseSensitiveFileNames']>;
54 getNewLine: NonNullable<typescript.LanguageServiceHost['getNewLine']>;
55 getDefaultLibFileName: NonNullable<typescript.LanguageServiceHost['getDefaultLibFileName']>;
56 readDirectory: NonNullable<typescript.LanguageServiceHost['readDirectory']>;
57}
58export interface ServiceHostWhichMayBeCacheable extends typescript.LanguageServiceHost, HostMayBeCacheable {
59}
60export interface WatchHost extends typescript.WatchCompilerHostOfFilesAndCompilerOptions<typescript.EmitAndSemanticDiagnosticsBuilderProgram> {
61 invokeFileWatcher: WatchFactory['invokeFileWatcher'];
62 updateRootFileNames(): void;
63 outputFiles: Map<FilePathKey, typescript.OutputFile[]>;
64 tsbuildinfo?: typescript.OutputFile;
65}
66export declare type WatchCallbacks<T> = Map<FilePathKey, {
67 fileName: string;
68 callbacks: T[];
69}>;
70export interface WatchFactory {
71 watchedFiles: WatchCallbacks<typescript.FileWatcherCallback>;
72 watchedDirectories: WatchCallbacks<typescript.DirectoryWatcherCallback>;
73 watchedDirectoriesRecursive: WatchCallbacks<typescript.DirectoryWatcherCallback>;
74 invokeFileWatcher(fileName: string, eventKind: typescript.FileWatcherEventKind): boolean;
75 /** Used to watch changes in source files, missing files needed to update the program or config file */
76 watchFile: typescript.WatchHost['watchFile'];
77 /** Used to watch resolved module's failed lookup locations, config file specs, type roots where auto type reference directives are added */
78 watchDirectory: typescript.WatchHost['watchDirectory'];
79}
80export interface SolutionDiagnostics {
81 global: typescript.Diagnostic[];
82 perFile: Map<FilePathKey, typescript.Diagnostic[]>;
83 transpileErrors: [FilePathKey | undefined, typescript.Diagnostic[]][];
84}
85export declare type FilePathKey = string & {
86 __filePathKeyBrand: any;
87};
88export interface SolutionBuilderWithWatchHost extends typescript.SolutionBuilderWithWatchHost<typescript.EmitAndSemanticDiagnosticsBuilderProgram>, WatchFactory {
89 diagnostics: SolutionDiagnostics;
90 writtenFiles: OutputFile[];
91 configFileInfo: Map<FilePathKey, ConfigFileInfo>;
92 outputAffectingInstanceVersion: Map<FilePathKey, true>;
93 getOutputFileKeyFromReferencedProject(outputFileName: string): FilePathKey | undefined;
94 getOutputFileFromReferencedProject(outputFileName: string): OutputFile | false | undefined;
95 getOutputFileAndKeyFromReferencedProject(oututFileName: string): {
96 key: FilePathKey;
97 outputFile: OutputFile | false;
98 } | undefined;
99 getInputFileNameFromOutput(outputFileName: string): string | undefined;
100 getOutputFilesFromReferencedProjectInput(inputFileName: string): OutputFile[];
101 buildReferences(): void;
102 clearCache(): void;
103}
104export interface ConfigFileInfo {
105 config: typescript.ParsedCommandLine | undefined;
106 outputFileNames?: Map<FilePathKey, {
107 inputFileName: string;
108 outputNames: FilePathKey[];
109 }>;
110 tsbuildInfoFile?: string;
111 dtsFiles?: string[];
112}
113export interface OutputFile extends typescript.OutputFile {
114 time: Date;
115 version: number;
116}
117export interface TSInstance {
118 compiler: typeof typescript;
119 compilerOptions: typescript.CompilerOptions;
120 /** Used for Vue for the most part */
121 appendTsTsxSuffixesIfRequired: (filePath: string) => string;
122 loaderOptions: LoaderOptions;
123 rootFileNames: Set<string>;
124 /**
125 * a cache of all the files
126 */
127 files: TSFiles;
128 /**
129 * contains the modified files - cleared each time after-compile is called
130 */
131 modifiedFiles?: Map<FilePathKey, true>;
132 /**
133 * Paths to project references that are missing source maps.
134 * Cleared each time after-compile is called. Used to dedupe
135 * warnings about source maps during a single compilation.
136 */
137 projectsMissingSourceMaps?: Set<string>;
138 servicesHost?: ServiceHostWhichMayBeCacheable;
139 languageService?: typescript.LanguageService | null;
140 version: number;
141 dependencyGraph: DependencyGraph;
142 filesWithErrors?: TSFiles;
143 transformers: typescript.CustomTransformers;
144 colors: Chalk;
145 otherFiles: TSFiles;
146 watchHost?: WatchHost;
147 watchOfFilesAndCompilerOptions?: typescript.WatchOfFilesAndCompilerOptions<typescript.EmitAndSemanticDiagnosticsBuilderProgram>;
148 builderProgram?: typescript.EmitAndSemanticDiagnosticsBuilderProgram;
149 program?: typescript.Program;
150 hasUnaccountedModifiedFiles?: boolean;
151 changedFilesList?: boolean;
152 reportTranspileErrors?: boolean;
153 solutionBuilderHost?: SolutionBuilderWithWatchHost;
154 solutionBuilder?: typescript.SolutionBuilder<typescript.EmitAndSemanticDiagnosticsBuilderProgram>;
155 configFilePath: string | undefined;
156 filePathKeyMapper: (fileName: string) => FilePathKey;
157 initialSetupPending: boolean;
158 configParseResult: typescript.ParsedCommandLine;
159 log: logger.Logger;
160}
161export interface LoaderOptionsCache {
162 [name: string]: WeakMap<LoaderOptions, LoaderOptions>;
163}
164export interface TSInstances {
165 [name: string]: TSInstance;
166}
167export declare type DependencyGraph = Map<FilePathKey, ResolvedModule[]>;
168export declare type ReverseDependencyGraph = Map<FilePathKey, Map<FilePathKey, true>>;
169export declare type LogLevel = 'INFO' | 'WARN' | 'ERROR';
170export declare type ResolveModuleName = (moduleName: string, containingFile: string, compilerOptions: typescript.CompilerOptions, moduleResolutionHost: typescript.ModuleResolutionHost) => typescript.ResolvedModuleWithFailedLookupLocations;
171export declare type CustomResolveModuleName = (moduleName: string, containingFile: string, compilerOptions: typescript.CompilerOptions, moduleResolutionHost: typescript.ModuleResolutionHost, parentResolver: ResolveModuleName) => typescript.ResolvedModuleWithFailedLookupLocations;
172export declare type CustomResolveTypeReferenceDirective = (typeDirectiveName: string, containingFile: string, compilerOptions: typescript.CompilerOptions, moduleResolutionHost: typescript.ModuleResolutionHost, parentResolver: typeof typescript.resolveTypeReferenceDirective) => typescript.ResolvedTypeReferenceDirectiveWithFailedLookupLocations;
173export interface LoaderOptions {
174 silent: boolean;
175 logLevel: LogLevel;
176 logInfoToStdOut: boolean;
177 instance: string;
178 compiler: string;
179 configFile: string;
180 context: string;
181 transpileOnly: boolean;
182 ignoreDiagnostics: number[];
183 reportFiles: string[];
184 errorFormatter: (message: ErrorInfo, colors: Chalk) => string;
185 onlyCompileBundledFiles: boolean;
186 colors: boolean;
187 compilerOptions: typescript.CompilerOptions;
188 appendTsSuffixTo: (RegExp | string)[];
189 appendTsxSuffixTo: (RegExp | string)[];
190 happyPackMode: boolean;
191 getCustomTransformers: string | ((program: typescript.Program) => typescript.CustomTransformers | undefined);
192 experimentalWatchApi: boolean;
193 allowTsInNodeModules: boolean;
194 experimentalFileCaching: boolean;
195 projectReferences: boolean;
196 resolveModuleName: CustomResolveModuleName;
197 resolveTypeReferenceDirective: CustomResolveTypeReferenceDirective;
198 useCaseSensitiveFileNames?: boolean;
199}
200export interface TSFile {
201 fileName: string;
202 text?: string;
203 version: number;
204 modifiedTime?: Date;
205 projectReference?: {
206 /**
207 * Undefined here means weve already checked and confirmed there is no
208 * project reference for the file. Dont bother checking again.
209 */
210 project?: typescript.ResolvedProjectReference;
211 outputFileName?: string;
212 };
213}
214/** where key is filepath */
215export declare type TSFiles = Map<FilePathKey, TSFile>;
216export interface ResolvedModule {
217 originalFileName: string;
218 resolvedFileName: string;
219 resolvedModule?: ResolvedModule;
220 isExternalLibraryImport?: boolean;
221}
222export declare type Severity = 'error' | 'warning';
223//# sourceMappingURL=interfaces.d.ts.map
\No newline at end of file