Fix Loader type in webpack

The sourcemap parameter passed to loaders, and that loaders pass to the
callback, is a `RawSourceMap`, not a `string | Buffer`.
This commit is contained in:
Jason Cheatham
2018-02-09 13:11:52 -05:00
parent a593fd2d60
commit 4a856368ec
3 changed files with 11 additions and 3 deletions

View File

@@ -9,12 +9,14 @@
// Ahmed T. Ali <https://github.com/ahmed-taj>
// Alan Agius <https://github.com/alan-agius4>
// Spencer Elliott <https://github.com/elliottsj>
// Jason Cheatham <https://github.com/jason0x43>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
import Tapable = require('tapable');
import * as UglifyJS from 'uglify-js';
import { RawSourceMap } from 'source-map';
export = webpack;
@@ -1020,7 +1022,7 @@ declare namespace webpack {
namespace loader {
interface Loader extends Function {
(this: LoaderContext, source: string | Buffer, sourceMap: string | Buffer): string | Buffer | void | undefined;
(this: LoaderContext, source: string | Buffer, sourceMap?: RawSourceMap): string | Buffer | void | undefined;
/**
* The order of chained loaders are always called from right to left.
@@ -1040,7 +1042,7 @@ declare namespace webpack {
raw?: boolean;
}
type loaderCallback = (err: Error | undefined | null, content?: string | Buffer, sourceMap?: string | Buffer) => void;
type loaderCallback = (err: Error | undefined | null, content?: string | Buffer, sourceMap?: RawSourceMap) => void;
interface LoaderContext {
/**

View File

@@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"source-map": "^0.7.0"
}
}

View File

@@ -637,7 +637,7 @@ configuration = {
performance,
};
function loader(this: webpack.loader.LoaderContext, source: string | Buffer, sourcemap: string | Buffer): void {
function loader(this: webpack.loader.LoaderContext, source: string | Buffer, sourcemap?: object): void {
this.cacheable();
this.async();