Skip to content

Commit 13c8987

Browse files
committed
Add error messages
1 parent adcaa87 commit 13c8987

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/trace-mapping/src/trace-mapping.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import type {
3737
EachMapping,
3838
Bias,
3939
XInput,
40+
SectionedSourceMap,
4041
} from './types';
4142
import type { Source } from './by-source';
4243
import type { MemoState } from './binary-search';
@@ -124,9 +125,13 @@ export class TraceMap implements SourceMap {
124125
if (typeof mappings === 'string') {
125126
this._encoded = mappings;
126127
this._decoded = undefined;
127-
} else {
128+
} else if (Array.isArray(mappings)) {
128129
this._encoded = undefined;
129130
this._decoded = maybeSort(mappings, isString);
131+
} else if ((parsed as unknown as SectionedSourceMap).sections) {
132+
throw new Error(`TraceMap passed sectioned source map, please use AnyMap export instead`);
133+
} else {
134+
throw new Error(`invalid source map: ${JSON.stringify(parsed)}`);
130135
}
131136

132137
this._decodedMemo = memoizedState();

0 commit comments

Comments
 (0)