Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit cb15d24

Browse files
committedFeb 13, 2019
import sourcemap type from source-map
1 parent 2751d9d commit cb15d24

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed
 

‎packages/jest-types/package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,8 @@
1111
},
1212
"license": "MIT",
1313
"main": "build/index.js",
14-
"types": "build/index.d.ts"
14+
"types": "build/index.d.ts",
15+
"dependencies": {
16+
"source-map": "^0.6.1"
17+
}
1518
}

‎packages/jest-types/src/Transform.ts

+11-12
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,21 @@
66
*/
77

88
import {Script} from 'vm';
9+
import {RawSourceMap} from 'source-map';
910
import {Path, ProjectConfig} from './Config';
1011

12+
// https://stackoverflow.com/a/48216010/1850276
13+
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
14+
15+
// This is fixed in a newer version, but that depends on Node 8 which is a
16+
// breaking change (engine warning when installing)
17+
interface FixedRawSourceMap extends Omit<RawSourceMap, 'version'> {
18+
version: number;
19+
}
20+
1121
export type TransformedSource = {
1222
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-
}
23-
| string
24-
| null;
23+
map?: FixedRawSourceMap | string | null;
2524
};
2625

2726
export type TransformResult = {

0 commit comments

Comments
 (0)
Please sign in to comment.