Skip to content

Commit b427780

Browse files
committed
sourcemap can be a string
1 parent 38bb80f commit b427780

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

packages/babel-jest/src/__tests__/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ test(`Returns source string with inline maps when no transformOptions is passed`
3636
expect(result.map).toBeDefined();
3737
expect(result.code).toMatch('//# sourceMappingURL');
3838
expect(result.code).toMatch('customMultiply');
39-
expect(result.map!.sources).toEqual(['dummy_path.js']);
40-
expect(JSON.stringify(result.map!.sourcesContent)).toMatch('customMultiply');
39+
// @ts-ignore: it's fine if we get wrong types, the tests will fail then
40+
expect(result.map.sources).toEqual(['dummy_path.js']);
41+
// @ts-ignore: it's fine if we get wrong types, the tests will fail then
42+
expect(JSON.stringify(result.map.sourcesContent)).toMatch('customMultiply');
4143
});

packages/jest-types/src/Transform.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,18 @@ import {Path, ProjectConfig} from './Config';
1010

1111
export type TransformedSource = {
1212
code: string;
13-
map?: // copied from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/363cdf403a74e0372e87bbcd15eb1668f4c5230b/types/babel__core/index.d.ts#L371-L379
14-
{
15-
version: number;
16-
sources: string[];
17-
names: string[];
18-
sourceRoot?: string;
19-
sourcesContent?: string[];
20-
mappings: string;
21-
file: string;
22-
} | null;
13+
map?: // copied from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/363cdf403a74e0372e87bbcd15eb1668f4c5230b/types/babel__core/index.d.ts#L371-L379
14+
| {
15+
version: number;
16+
sources: string[];
17+
names: string[];
18+
sourceRoot?: string;
19+
sourcesContent?: string[];
20+
mappings: string;
21+
file: string;
22+
}
23+
| string
24+
| null;
2325
};
2426

2527
export type TransformResult = {

0 commit comments

Comments
 (0)