From 27b6dce48f75469906d9aeecad06b4e05d1edc93 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sat, 11 Mar 2023 08:19:40 +0530 Subject: [PATCH] fix: improve types for `webpack-sources` --- declarations.d.ts | 12 +++++++++++- types.d.ts | 11 ++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/declarations.d.ts b/declarations.d.ts index ea7c1ab61..ea8207f8e 100644 --- a/declarations.d.ts +++ b/declarations.d.ts @@ -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; diff --git a/types.d.ts b/types.d.ts index ded8f2f49..ab6dabf57 100644 --- a/types.d.ts +++ b/types.d.ts @@ -8934,6 +8934,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; @@ -10643,7 +10652,7 @@ declare abstract class SortableSet extends Set { 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;