Skip to content

Commit 796b511

Browse files
authored
Merge pull request webpack#16805 from snitin315/fix/improve-source-types
Improve types for `webpack-sources` to match in webpack core.
2 parents be54e43 + 27b6dce commit 796b511

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

declarations.d.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,20 @@ declare module "@webassemblyjs/ast" {
246246
declare module "webpack-sources" {
247247
export type MapOptions = { columns?: boolean; module?: boolean };
248248

249+
export type RawSourceMap = {
250+
version: number;
251+
sources: string[];
252+
names: string[];
253+
sourceRoot?: string;
254+
sourcesContent?: string[];
255+
mappings: string;
256+
file: string;
257+
};
258+
249259
export abstract class Source {
250260
size(): number;
251261

252-
map(options?: MapOptions): Object;
262+
map(options?: MapOptions): RawSourceMap | null;
253263

254264
sourceAndMap(options?: MapOptions): {
255265
source: string | Buffer;

types.d.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -9358,6 +9358,15 @@ declare class RawSource extends Source {
93589358
constructor(source: string | Buffer, convertToString?: boolean);
93599359
isBuffer(): boolean;
93609360
}
9361+
declare interface RawSourceMap {
9362+
version: number;
9363+
sources: string[];
9364+
names: string[];
9365+
sourceRoot?: string;
9366+
sourcesContent?: string[];
9367+
mappings: string;
9368+
file: string;
9369+
}
93619370
declare class ReadFileCompileWasmPlugin {
93629371
constructor(options?: any);
93639372
options: any;
@@ -11104,7 +11113,7 @@ declare abstract class SortableSet<T> extends Set<T> {
1110411113
declare class Source {
1110511114
constructor();
1110611115
size(): number;
11107-
map(options?: MapOptions): Object;
11116+
map(options?: MapOptions): null | RawSourceMap;
1110811117
sourceAndMap(options?: MapOptions): { source: string | Buffer; map: Object };
1110911118
updateHash(hash: Hash): void;
1111011119
source(): string | Buffer;

0 commit comments

Comments
 (0)