index.d.ts 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import { BaseError } from 'make-error';
  2. import * as TS from 'typescript';
  3. export interface TSCommon {
  4. version: typeof TS.version;
  5. sys: typeof TS.sys;
  6. ScriptSnapshot: typeof TS.ScriptSnapshot;
  7. displayPartsToString: typeof TS.displayPartsToString;
  8. createLanguageService: typeof TS.createLanguageService;
  9. getDefaultLibFilePath: typeof TS.getDefaultLibFilePath;
  10. getPreEmitDiagnostics: typeof TS.getPreEmitDiagnostics;
  11. flattenDiagnosticMessageText: typeof TS.flattenDiagnosticMessageText;
  12. transpileModule: typeof TS.transpileModule;
  13. ModuleKind: typeof TS.ModuleKind;
  14. ScriptTarget: typeof TS.ScriptTarget;
  15. findConfigFile: typeof TS.findConfigFile;
  16. readConfigFile: typeof TS.readConfigFile;
  17. parseJsonConfigFileContent: typeof TS.parseJsonConfigFileContent;
  18. }
  19. export declare const VERSION: any;
  20. export interface Options {
  21. typeCheck?: boolean | null;
  22. cache?: boolean | null;
  23. cacheDirectory?: string;
  24. compiler?: string;
  25. ignore?: string | string[];
  26. project?: string;
  27. skipIgnore?: boolean | null;
  28. skipProject?: boolean | null;
  29. compilerOptions?: object;
  30. ignoreDiagnostics?: number | string | Array<number | string>;
  31. readFile?: (path: string) => string | undefined;
  32. fileExists?: (path: string) => boolean;
  33. transformers?: TS.CustomTransformers;
  34. }
  35. export interface TypeInfo {
  36. name: string;
  37. comment: string;
  38. }
  39. export declare const DEFAULTS: Options;
  40. export declare function split(value: string | undefined): string[] | undefined;
  41. export declare function parse(value: string | undefined): object | undefined;
  42. export declare function normalizeSlashes(value: string): string;
  43. export declare class TSError extends BaseError {
  44. diagnostics: TSDiagnostic[];
  45. name: string;
  46. constructor(diagnostics: TSDiagnostic[]);
  47. }
  48. export interface Register {
  49. cwd: string;
  50. extensions: string[];
  51. cachedir: string;
  52. ts: TSCommon;
  53. compile(code: string, fileName: string, lineOffset?: number): string;
  54. getTypeInfo(code: string, fileName: string, position: number): TypeInfo;
  55. }
  56. export declare function register(opts?: Options): Register;
  57. export declare function formatDiagnostics(diagnostics: TS.Diagnostic[], cwd: string, ts: TSCommon, lineOffset: number): TSDiagnostic[];
  58. export interface TSDiagnostic {
  59. message: string;
  60. code: number;
  61. }
  62. export declare function formatDiagnostic(diagnostic: TS.Diagnostic, cwd: string, ts: TSCommon, lineOffset: number): TSDiagnostic;
  63. export declare function printError(error: TSError): string;