Webpack provides a TypeScript interface for implementing a loader:
import { loader } from "webpack";
namespace loader {
interface Loader extends Function {
(this: LoaderContext, source: string | Buffer, sourceMap?: RawSourceMap): string | Buffer | void | undefined;
pitch?(remainingRequest: string, precedingRequest: string, data: any): any;
raw?: boolean;
}
}
So when I implement that I do
const sfcLoader: loader.Loader = function(source: string) {
/* ... */
};
Now I am trying to create an interface that is that interface but returns a Promise:
const sfcLoader /* : loader.Loader */ = async function(source: string) {
/* await ... */
};
Note that async
Of course I don't want to copy and paste that interface. Is there a way I can extend (or something) and modify the interface from webpack?