Skip to content

Commit

Permalink
Merge pull request #16805 from snitin315/fix/improve-source-types
Browse files Browse the repository at this point in the history
Improve types for `webpack-sources` to match in webpack core.
  • Loading branch information
TheLarkInn committed Mar 14, 2023
2 parents be54e43 + 27b6dce commit 796b511
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
12 changes: 11 additions & 1 deletion declarations.d.ts
Expand Up @@ -246,10 +246,20 @@ declare module "@webassemblyjs/ast" {
declare module "webpack-sources" {
export type MapOptions = { columns?: boolean; module?: boolean };

export type RawSourceMap = {
version: number;
sources: string[];
names: string[];
sourceRoot?: string;
sourcesContent?: string[];
mappings: string;
file: string;
};

export abstract class Source {
size(): number;

map(options?: MapOptions): Object;
map(options?: MapOptions): RawSourceMap | null;

sourceAndMap(options?: MapOptions): {
source: string | Buffer;
Expand Down
11 changes: 10 additions & 1 deletion types.d.ts
Expand Up @@ -9358,6 +9358,15 @@ declare class RawSource extends Source {
constructor(source: string | Buffer, convertToString?: boolean);
isBuffer(): boolean;
}
declare interface RawSourceMap {
version: number;
sources: string[];
names: string[];
sourceRoot?: string;
sourcesContent?: string[];
mappings: string;
file: string;
}
declare class ReadFileCompileWasmPlugin {
constructor(options?: any);
options: any;
Expand Down Expand Up @@ -11104,7 +11113,7 @@ declare abstract class SortableSet<T> extends Set<T> {
declare class Source {
constructor();
size(): number;
map(options?: MapOptions): Object;
map(options?: MapOptions): null | RawSourceMap;
sourceAndMap(options?: MapOptions): { source: string | Buffer; map: Object };
updateHash(hash: Hash): void;
source(): string | Buffer;
Expand Down

0 comments on commit 796b511

Please sign in to comment.