mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-01-30 13:37:35 +00:00
fix: improve missing typings
This commit is contained in:
parent
822f53a17b
commit
f9387518fa
49
loader-runner/index.d.ts
vendored
49
loader-runner/index.d.ts
vendored
@ -10,26 +10,63 @@ export interface Loader {
|
||||
query: string;
|
||||
request: string;
|
||||
options: any;
|
||||
normal: any;
|
||||
pitch: any;
|
||||
normal: null | ((request: string) => string);
|
||||
pitch: null | ((request: string) => string);
|
||||
raw: string;
|
||||
data: any;
|
||||
pitchExecuted: boolean;
|
||||
normalExecuted: boolean;
|
||||
}
|
||||
|
||||
export function getContext(resource: string): string;
|
||||
|
||||
export interface RunLoaderOption {
|
||||
resource: string;
|
||||
loaders: any[];
|
||||
context: any;
|
||||
readResource: (filename: string, callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void) => void;
|
||||
readResource: (
|
||||
filename: string,
|
||||
callback: (err: NodeJS.ErrnoException | null, data: Buffer | null) => void
|
||||
) => void;
|
||||
}
|
||||
|
||||
export interface RunLoaderResult {
|
||||
result?: (Buffer | null)[];
|
||||
resourceBuffer?: Buffer | null;
|
||||
cacheable: boolean;
|
||||
fileDependencies: string[];
|
||||
contextDependencies: string[];
|
||||
}
|
||||
|
||||
export interface ExtendedLoaderContext {
|
||||
context: string | null;
|
||||
loaderIndex: number;
|
||||
loaders: Loader[];
|
||||
resourcePath: string | undefined;
|
||||
resourceQuery: string | undefined;
|
||||
async: (() => (() => void) | undefined) | null;
|
||||
callback: (() => void) | null;
|
||||
cacheable: (flag: boolean) => void;
|
||||
dependency: (file: string) => void;
|
||||
addDependency: (file: string) => void;
|
||||
addContextDependency: (context: string) => void;
|
||||
getDependencies: () => string[];
|
||||
getContextDependencies: () => string[];
|
||||
clearDependencies: () => void;
|
||||
resource: string;
|
||||
request: string;
|
||||
remainingRequest: string;
|
||||
currentRequest: string;
|
||||
previousRequest: string;
|
||||
query: {
|
||||
[key: string]: any;
|
||||
} | string;
|
||||
data: any;
|
||||
}
|
||||
|
||||
export function getContext(resource: string): string;
|
||||
|
||||
export function runLoaders(
|
||||
options: RunLoaderOption,
|
||||
callback: (err: NodeJS.ErrnoException | null, result: any) => any
|
||||
callback: (err: NodeJS.ErrnoException | null, result: RunLoaderResult) => any
|
||||
): void;
|
||||
|
||||
|
||||
|
||||
@ -1,10 +1,19 @@
|
||||
import { runLoaders, getContext, Loader, RunLoaderOption } from 'loader-runner';
|
||||
import { runLoaders, getContext } from 'loader-runner';
|
||||
|
||||
const option = {} as RunLoaderOption;
|
||||
const option = {
|
||||
resource: 'test.js',
|
||||
loaders: [{
|
||||
request: 'test.js'
|
||||
}],
|
||||
context: './lib/',
|
||||
readResource: function () {
|
||||
}
|
||||
};
|
||||
|
||||
runLoaders(option, function (err, result) {
|
||||
if(err)
|
||||
if (err) {
|
||||
console.log(err, result);
|
||||
}
|
||||
});
|
||||
|
||||
getContext('sdlfkjaldfjiojsdf');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user