index.d.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. declare module 'pretty-error' {
  2. namespace PrettyError {
  3. function start(): any;
  4. function stop(): any;
  5. class ParsedError {
  6. constructor(error: Error);
  7. }
  8. interface ConfigObject {
  9. skipPackages?: boolean | string[];
  10. skipPaths?: boolean | string[];
  11. skip?: boolean | PrettyError.Callback | PrettyError.Callback[];
  12. maxItems?: number;
  13. skipNodeFiles?: boolean | any; // assuming this is optional
  14. filters?: boolean | PrettyError.Callback | PrettyError.Callback[];
  15. parsedErrorFilters?:
  16. | boolean
  17. | PrettyError.Callback
  18. | PrettyError.Callback[];
  19. aliases?: boolean | Object;
  20. }
  21. type Callback = (traceLine: Object | any, lineNumber: number) => boolean;
  22. }
  23. class PrettyError {
  24. constructor();
  25. start(): PrettyError;
  26. stop(): any;
  27. config(configObject: PrettyError.ConfigObject): PrettyError;
  28. withoutColors(): PrettyError;
  29. withColors(): PrettyError;
  30. skipPackage(...packages: string[]): PrettyError;
  31. unskipPackage(...packages: string[]): PrettyError;
  32. unskipAllPackages(): PrettyError;
  33. skipPath(...paths: string[]): PrettyError;
  34. unskipPath(...paths: string[]): PrettyError;
  35. unskipAllPaths(): PrettyError;
  36. skip(callbacks: PrettyError.Callback): PrettyError;
  37. unskip(callbacks: PrettyError.Callback): PrettyError;
  38. unskipAll(): PrettyError;
  39. skipNodeFiles(): any;
  40. unskipNodeFiles(): any;
  41. filter(callbacks: PrettyError.Callback): PrettyError;
  42. removeFilter(callbacks: PrettyError.Callback): PrettyError;
  43. removeAllFilters(): PrettyError;
  44. filterParsedError(callbacks: PrettyError.Callback): PrettyError;
  45. removeParsedErrorFilter(callbacks: PrettyError.Callback): PrettyError;
  46. removeAllParsedErrorFilters(): PrettyError;
  47. setMaxItems(maxItems: number): PrettyError;
  48. alias(stringOrRx: string, alias: string): PrettyError;
  49. removeAlias(stringOrRx: string): PrettyError;
  50. removeAllAliases(): PrettyError;
  51. appendStyle(toAppend: Object): PrettyError;
  52. render(
  53. e: PrettyError.ParsedError,
  54. logIt?: boolean,
  55. useColors?: boolean
  56. ): string;
  57. getObject(e: Object): Object;
  58. }
  59. export = PrettyError;
  60. }