Skip to content

Commit

Permalink
import sourcemap type from source-map
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Feb 13, 2019
1 parent 2751d9d commit d3e84e6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
5 changes: 4 additions & 1 deletion packages/jest-types/package.json
Expand Up @@ -11,5 +11,8 @@
},
"license": "MIT",
"main": "build/index.js",
"types": "build/index.d.ts"
"types": "build/index.d.ts",
"dependencies": {
"source-map": "^0.6.1"
}
}
23 changes: 11 additions & 12 deletions packages/jest-types/src/Transform.ts
Expand Up @@ -6,22 +6,21 @@
*/

import {Script} from 'vm';
import {RawSourceMap} from 'source-map';
import {Path, ProjectConfig} from './Config';

// https://stackoverflow.com/a/48216010/1850276
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;

// This is fixed in a newer version, but that depends on Node 8 which is a
// breaking change (engine warning when installing)
interface FixedRawSourceMap extends Omit<RawSourceMap, 'version'> {
version: number;
}

export type TransformedSource = {
code: string;
map?: // copied from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/363cdf403a74e0372e87bbcd15eb1668f4c5230b/types/babel__core/index.d.ts#L371-L379
| {
version: number;
sources: string[];
names: string[];
sourceRoot?: string;
sourcesContent?: string[];
mappings: string;
file: string;
}
| string
| null;
map?: FixedRawSourceMap | null | string;
};

export type TransformResult = {
Expand Down

0 comments on commit d3e84e6

Please sign in to comment.