Skip to content

Commit

Permalink
Use sourcemap-codec's types
Browse files Browse the repository at this point in the history
  • Loading branch information
jridgewell committed Jul 6, 2019
1 parent aaa0558 commit f936eeb
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/utils/collapseSourcemaps.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { DecodedSourceMap, SourceMap } from 'magic-string';
import { SourceMapLine, SourceMapMappings, SourceMapSegment } from 'sourcemap-codec';
import Chunk from '../Chunk';
import Module from '../Module';
import { DecodedSourceMapOrMissing } from '../rollup/types';
Expand All @@ -21,11 +22,6 @@ class Source {
}
}

type SourceMapSegmentVector =
| [number]
| [number, number, number, number]
| [number, number, number, number, number];

interface SourceMapSegmentObject {
column: number;
line: number;
Expand All @@ -34,14 +30,14 @@ interface SourceMapSegmentObject {
}

class Link {
mappings: SourceMapSegmentVector[][];
mappings: SourceMapMappings;
names: string[];
sources: (Source | Link)[];

constructor(map: { mappings: number[][][]; names: string[] }, sources: (Source | Link)[]) {
this.sources = sources;
this.names = map.names;
this.mappings = map.mappings as SourceMapSegmentVector[][];
this.mappings = map.mappings as SourceMapMappings;
}

traceMappings() {
Expand All @@ -52,7 +48,7 @@ class Link {
const mappings = [];

for (const line of this.mappings) {
const tracedLine: SourceMapSegmentVector[] = [];
const tracedLine: SourceMapLine = [];

for (const segment of line) {
if (segment.length == 1) continue;
Expand Down Expand Up @@ -83,7 +79,7 @@ class Link {
});
}

const tracedSegment: SourceMapSegmentVector = [
const tracedSegment: SourceMapSegment = [
segment[0],
sourceIndex,
traced.line,
Expand All @@ -97,7 +93,7 @@ class Link {
names.push(traced.name);
}

(tracedSegment as SourceMapSegmentVector)[4] = nameIndex;
(tracedSegment as SourceMapSegment)[4] = nameIndex;
}

tracedLine.push(tracedSegment);
Expand Down

0 comments on commit f936eeb

Please sign in to comment.