Skip to content

Commit bd538e4

Browse files
Improve ts declarations (#27)
Co-authored-by: Valentin Semirulnik <v7rulnik@gmail.com>
1 parent 0f58a3f commit bd538e4

1 file changed

Lines changed: 16 additions & 10 deletions

File tree

source-map.d.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ export interface MappedPosition extends Position {
3535
}
3636

3737
export interface MappingItem {
38-
source: string;
38+
source: string | null;
3939
generatedLine: number;
4040
generatedColumn: number;
41-
originalLine: number;
42-
originalColumn: number;
43-
name: string;
41+
originalLine: number | null;
42+
originalColumn: number | null;
43+
name: string | null;
4444
}
4545

4646
export class SourceMapConsumer {
@@ -51,29 +51,35 @@ export class SourceMapConsumer {
5151
static LEAST_UPPER_BOUND: number;
5252

5353
constructor(rawSourceMap: RawSourceMap);
54+
readonly file: string | undefined | null;
55+
readonly sourceRoot: string | undefined | null;
56+
readonly sourcesContent: readonly string[] | null | undefined;
57+
readonly sources: readonly string[]
58+
5459
computeColumnSpans(): void;
5560
originalPositionFor(generatedPosition: FindPosition): MappedPosition;
5661
generatedPositionFor(originalPosition: SourceFindPosition): LineRange;
5762
allGeneratedPositionsFor(originalPosition: MappedPosition): Position[];
5863
hasContentsOfAllSources(): boolean;
59-
sourceContentFor(source: string, returnNullOnMissing?: boolean): string;
64+
sourceContentFor(source: string, returnNullOnMissing?: boolean): string | null;
6065
eachMapping(callback: (mapping: MappingItem) => void, context?: any, order?: number): void;
6166
}
6267

6368
export interface Mapping {
6469
generated: Position;
65-
original: Position;
66-
source: string;
67-
name?: string;
70+
original?: Position | null;
71+
source?: string | null;
72+
name?: string | null;
6873
}
6974

7075
export class SourceMapGenerator {
7176
constructor(startOfSourceMap?: StartOfSourceMap);
72-
static fromSourceMap(sourceMapConsumer: SourceMapConsumer): SourceMapGenerator;
77+
static fromSourceMap(sourceMapConsumer: SourceMapConsumer, startOfSourceMap?: StartOfSourceMap): SourceMapGenerator;
7378
addMapping(mapping: Mapping): void;
74-
setSourceContent(sourceFile: string, sourceContent: string): void;
79+
setSourceContent(sourceFile: string, sourceContent: string | null | undefined): void;
7580
applySourceMap(sourceMapConsumer: SourceMapConsumer, sourceFile?: string, sourceMapPath?: string): void;
7681
toString(): string;
82+
toJSON(): RawSourceMap;
7783
}
7884

7985
export interface CodeWithSourceMap {

0 commit comments

Comments
 (0)