-
Notifications
You must be signed in to change notification settings - Fork 2
/
Loader.ts
28 lines (26 loc) · 901 Bytes
/
Loader.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/**
* The loader class. A loader is able to load a file of a given type.
*/
export default interface Loader {
/**
* Asynchronously load the given file.
*
* @param fileName - The name of the file to load.
* @returns The content or undefined if content not found.
*/
load(fileName: string): Promise<unknown | undefined>
/**
* Synchronously load the given file. May not exist on all loaders.
*
* @param fileName - The name of the file to load.
* @returns The content or undefined if content not found.
*/
syncLoad?(fileName: string): unknown | undefined
}
/**
* A loader type. If it is not a `LoaderDescription`, it will not be automatically used by the loader
* manager, but may be directly provided for a given file (e.g. the `package.json` entry loader).
*/
export interface LoaderType<T extends any[]> {
Loader: new (required: any, ..._: T) => Loader
}