Add type definitions for source-map library.
This commit is contained in:
parent
e31e907d5f
commit
9e7fe0ab49
@ -32,16 +32,118 @@ declare module "lodash/merge" {
|
|||||||
declare export default <T: Object>(T, Object) => T;
|
declare export default <T: Object>(T, Object) => T;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare module "convert-source-map" {
|
declare module "source-map" {
|
||||||
declare export type SourceMap = {
|
declare export type SourceMap = {
|
||||||
version: 3,
|
version: 3,
|
||||||
file: ?string,
|
file: ?string,
|
||||||
|
sourceRoot: ?string,
|
||||||
sources: [?string],
|
sources: [?string],
|
||||||
sourcesContent: [?string],
|
sourcesContent: [?string],
|
||||||
names: [?string],
|
names: [?string],
|
||||||
mappings: string,
|
mappings: string,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
declare module.exports: {
|
||||||
|
SourceMapConsumer: typeof SourceMapConsumer,
|
||||||
|
SourceMapGenerator: typeof SourceMapGenerator,
|
||||||
|
}
|
||||||
|
|
||||||
|
declare class SourceMapConsumer {
|
||||||
|
static GENERATED_ORDER: 1;
|
||||||
|
static ORIGINAL_ORDER: 2;
|
||||||
|
|
||||||
|
file: string | null;
|
||||||
|
sourceRoot: string | null;
|
||||||
|
sources: Array<string>;
|
||||||
|
|
||||||
|
constructor(?SourceMap): this;
|
||||||
|
|
||||||
|
computeColumnSpans(): string;
|
||||||
|
originalPositionFor({
|
||||||
|
line: number,
|
||||||
|
column: number,
|
||||||
|
}): {|
|
||||||
|
source: string,
|
||||||
|
line: number,
|
||||||
|
column: number,
|
||||||
|
name: string | null
|
||||||
|
|} | {|
|
||||||
|
source: null,
|
||||||
|
line: null,
|
||||||
|
column: null,
|
||||||
|
name: null
|
||||||
|
|};
|
||||||
|
|
||||||
|
generatedPositionFor({
|
||||||
|
source: string,
|
||||||
|
line: number,
|
||||||
|
column: number,
|
||||||
|
}): {|
|
||||||
|
line: number,
|
||||||
|
column: number,
|
||||||
|
lastColumn: number | null | void,
|
||||||
|
|} | {|
|
||||||
|
line: null,
|
||||||
|
column: null,
|
||||||
|
lastColumn: null | void,
|
||||||
|
|};
|
||||||
|
|
||||||
|
allGeneratedPositionsFor({
|
||||||
|
source: string,
|
||||||
|
line: number,
|
||||||
|
column: number,
|
||||||
|
}): Array<{|
|
||||||
|
line: number,
|
||||||
|
column: number,
|
||||||
|
lastColumn: number,
|
||||||
|
|}>;
|
||||||
|
|
||||||
|
sourceContentFor(string, boolean | void): string | null;
|
||||||
|
|
||||||
|
eachMapping(
|
||||||
|
({|
|
||||||
|
generatedLine: number,
|
||||||
|
generatedColumn: number,
|
||||||
|
source: string,
|
||||||
|
originalLine: number,
|
||||||
|
originalColumn: number,
|
||||||
|
name: string | null,
|
||||||
|
|} | {|
|
||||||
|
generatedLine: number,
|
||||||
|
generatedColumn: number,
|
||||||
|
source: null,
|
||||||
|
originalLine: null,
|
||||||
|
originalColumn: null,
|
||||||
|
name: null,
|
||||||
|
|}) => mixed,
|
||||||
|
context: mixed,
|
||||||
|
order: ?(1 | 2),
|
||||||
|
): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare class SourceMapGenerator {
|
||||||
|
constructor(?{
|
||||||
|
file?: string | null,
|
||||||
|
sourceRoot?: string | null,
|
||||||
|
skipValidation?: boolean | null,
|
||||||
|
}): this;
|
||||||
|
|
||||||
|
addMapping({
|
||||||
|
generated: {
|
||||||
|
line: number,
|
||||||
|
column: number,
|
||||||
|
}
|
||||||
|
}): void;
|
||||||
|
|
||||||
|
setSourceContent(string, string): void;
|
||||||
|
|
||||||
|
toJSON(): SourceMap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module "convert-source-map" {
|
||||||
|
import type { SourceMap } from "source-map";
|
||||||
|
|
||||||
declare class Converter {
|
declare class Converter {
|
||||||
toJSON(): string;
|
toJSON(): string;
|
||||||
toBase64(): string;
|
toBase64(): string;
|
||||||
|
|||||||
@ -25,7 +25,12 @@ export default function mergeSourceMap(
|
|||||||
column: mapping.generatedColumn,
|
column: mapping.generatedColumn,
|
||||||
source: source,
|
source: source,
|
||||||
});
|
});
|
||||||
if (generatedPosition.column != null) {
|
if (generatedPosition.line != null && generatedPosition.column != null) {
|
||||||
|
const generated = {
|
||||||
|
line: generatedPosition.line,
|
||||||
|
column: generatedPosition.column,
|
||||||
|
};
|
||||||
|
|
||||||
mergedGenerator.addMapping({
|
mergedGenerator.addMapping({
|
||||||
source: mapping.source,
|
source: mapping.source,
|
||||||
|
|
||||||
@ -37,7 +42,7 @@ export default function mergeSourceMap(
|
|||||||
column: mapping.originalColumn,
|
column: mapping.originalColumn,
|
||||||
},
|
},
|
||||||
|
|
||||||
generated: generatedPosition,
|
generated,
|
||||||
|
|
||||||
name: mapping.name,
|
name: mapping.name,
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user