index.d.ts 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. import { BaseError } from 'make-error';
  2. import * as _ts from 'typescript';
  3. /**
  4. * @internal
  5. */
  6. export declare const INSPECT_CUSTOM: symbol;
  7. /**
  8. * Common TypeScript interfaces between versions.
  9. */
  10. export interface TSCommon {
  11. version: typeof _ts.version;
  12. sys: typeof _ts.sys;
  13. ScriptSnapshot: typeof _ts.ScriptSnapshot;
  14. displayPartsToString: typeof _ts.displayPartsToString;
  15. createLanguageService: typeof _ts.createLanguageService;
  16. getDefaultLibFilePath: typeof _ts.getDefaultLibFilePath;
  17. getPreEmitDiagnostics: typeof _ts.getPreEmitDiagnostics;
  18. flattenDiagnosticMessageText: typeof _ts.flattenDiagnosticMessageText;
  19. transpileModule: typeof _ts.transpileModule;
  20. ModuleKind: typeof _ts.ModuleKind;
  21. ScriptTarget: typeof _ts.ScriptTarget;
  22. findConfigFile: typeof _ts.findConfigFile;
  23. readConfigFile: typeof _ts.readConfigFile;
  24. parseJsonConfigFileContent: typeof _ts.parseJsonConfigFileContent;
  25. formatDiagnostics: typeof _ts.formatDiagnostics;
  26. formatDiagnosticsWithColorAndContext: typeof _ts.formatDiagnosticsWithColorAndContext;
  27. }
  28. /**
  29. * Export the current version.
  30. */
  31. export declare const VERSION: any;
  32. /**
  33. * Registration options.
  34. */
  35. export interface Options {
  36. pretty?: boolean | null;
  37. typeCheck?: boolean | null;
  38. transpileOnly?: boolean | null;
  39. files?: boolean | null;
  40. cache?: boolean | null;
  41. cacheDirectory?: string;
  42. compiler?: string;
  43. ignore?: string | string[];
  44. project?: string;
  45. skipIgnore?: boolean | null;
  46. skipProject?: boolean | null;
  47. compilerOptions?: object;
  48. ignoreDiagnostics?: number | string | Array<number | string>;
  49. readFile?: (path: string) => string | undefined;
  50. fileExists?: (path: string) => boolean;
  51. transformers?: _ts.CustomTransformers;
  52. }
  53. /**
  54. * Information retrieved from type info check.
  55. */
  56. export interface TypeInfo {
  57. name: string;
  58. comment: string;
  59. }
  60. /**
  61. * Default register options.
  62. */
  63. export declare const DEFAULTS: Options;
  64. /**
  65. * Split a string array of values.
  66. */
  67. export declare function split(value: string | undefined): string[] | undefined;
  68. /**
  69. * Parse a string as JSON.
  70. */
  71. export declare function parse(value: string | undefined): object | undefined;
  72. /**
  73. * Replace backslashes with forward slashes.
  74. */
  75. export declare function normalizeSlashes(value: string): string;
  76. /**
  77. * TypeScript diagnostics error.
  78. */
  79. export declare class TSError extends BaseError {
  80. diagnosticText: string;
  81. diagnosticCodes: number[];
  82. name: string;
  83. constructor(diagnosticText: string, diagnosticCodes: number[]);
  84. }
  85. /**
  86. * Return type for registering `ts-node`.
  87. */
  88. export interface Register {
  89. cwd: string;
  90. extensions: string[];
  91. cachedir: string;
  92. ts: TSCommon;
  93. compile(code: string, fileName: string, lineOffset?: number): string;
  94. getTypeInfo(code: string, fileName: string, position: number): TypeInfo;
  95. }
  96. /**
  97. * Register TypeScript compiler.
  98. */
  99. export declare function register(opts?: Options): Register;