get-source.d.ts 928 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. declare interface Location {
  2. line: number;
  3. column: number;
  4. }
  5. declare interface ResolvedLocation<FileType> extends Location {
  6. sourceFile: FileType;
  7. sourceLine: string;
  8. error?: Error;
  9. }
  10. declare interface File {
  11. path: string;
  12. text: string;
  13. lines: string[];
  14. error?: Error;
  15. }
  16. declare interface FileAsync extends File {
  17. resolve (location: Location): Promise<ResolvedLocation<FileAsync>>
  18. }
  19. declare interface FileSync extends File {
  20. resolve (location: Location): ResolvedLocation<FileSync>
  21. }
  22. declare interface FileCache<T> {
  23. resetCache (): void;
  24. getCache (): { [key: string]: T };
  25. }
  26. declare interface getSourceAsync extends FileCache<FileAsync> {
  27. (path: string): Promise<FileAsync>;
  28. }
  29. declare interface getSourceSync extends FileCache<FileSync> {
  30. (path: string): FileSync;
  31. async: getSourceAsync;
  32. }
  33. declare const getSource: getSourceSync;
  34. export = getSource;