utils.d.ts 2.3 KB

123456789101112131415161718192021222324252627282930313233
  1. /// <reference types="node" />
  2. import type { Chalk } from 'chalk';
  3. import * as webpack from 'webpack';
  4. import type * as typescript from 'typescript';
  5. import type { FileLocation, FilePathKey, LoaderOptions, ResolvedModule, ReverseDependencyGraph, TSInstance } from './interfaces';
  6. /**
  7. * Take TypeScript errors, parse them and format to webpack errors
  8. * Optionally adds a file name
  9. */
  10. export declare function formatErrors(diagnostics: ReadonlyArray<typescript.Diagnostic> | undefined, loaderOptions: LoaderOptions, colors: Chalk, compiler: typeof typescript, merge: {
  11. file?: string;
  12. module?: webpack.Module;
  13. }, context: string): webpack.WebpackError[];
  14. export declare function fsReadFile(fileName: string, encoding?: BufferEncoding | undefined): string | undefined;
  15. export declare function makeError(loaderOptions: LoaderOptions, message: string, file: string, location?: FileLocation, endLocation?: FileLocation): webpack.WebpackError;
  16. export declare function tsLoaderSource(loaderOptions: LoaderOptions): string;
  17. export declare function appendSuffixIfMatch(patterns: (RegExp | string)[], filePath: string, suffix: string): string;
  18. export declare function appendSuffixesIfMatch(suffixDict: {
  19. [suffix: string]: (RegExp | string)[];
  20. }, filePath: string): string;
  21. export declare function unorderedRemoveItem<T>(array: T[], item: T): boolean;
  22. export declare function populateDependencyGraph(resolvedModules: ResolvedModule[], instance: TSInstance, containingFile: string): void;
  23. export declare function populateReverseDependencyGraph(instance: TSInstance): ReverseDependencyGraph;
  24. /**
  25. * Recursively collect all possible dependants of passed file
  26. */
  27. export declare function collectAllDependants(reverseDependencyGraph: ReverseDependencyGraph, fileName: FilePathKey, result?: Map<FilePathKey, true>): Map<FilePathKey, true>;
  28. export declare function arrify<T>(val: T | T[]): T[];
  29. export declare function ensureProgram(instance: TSInstance): typescript.Program | undefined;
  30. export declare function supportsSolutionBuild(instance: TSInstance): boolean;
  31. export declare function isReferencedFile(instance: TSInstance, filePath: string): boolean;
  32. export declare function useCaseSensitiveFileNames(compiler: typeof typescript, loaderOptions: LoaderOptions): boolean;
  33. //# sourceMappingURL=utils.d.ts.map