From b427780fe61632b1bd6a5f12261aea3eb9565632 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Mon, 11 Feb 2019 14:42:53 +0100 Subject: [PATCH] sourcemap can be a string --- packages/babel-jest/src/__tests__/index.ts | 6 ++++-- packages/jest-types/src/Transform.ts | 22 ++++++++++++---------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/packages/babel-jest/src/__tests__/index.ts b/packages/babel-jest/src/__tests__/index.ts index af0e84fa216b..01fbd54b92c9 100644 --- a/packages/babel-jest/src/__tests__/index.ts +++ b/packages/babel-jest/src/__tests__/index.ts @@ -36,6 +36,8 @@ test(`Returns source string with inline maps when no transformOptions is passed` expect(result.map).toBeDefined(); expect(result.code).toMatch('//# sourceMappingURL'); expect(result.code).toMatch('customMultiply'); - expect(result.map!.sources).toEqual(['dummy_path.js']); - expect(JSON.stringify(result.map!.sourcesContent)).toMatch('customMultiply'); + // @ts-ignore: it's fine if we get wrong types, the tests will fail then + expect(result.map.sources).toEqual(['dummy_path.js']); + // @ts-ignore: it's fine if we get wrong types, the tests will fail then + expect(JSON.stringify(result.map.sourcesContent)).toMatch('customMultiply'); }); diff --git a/packages/jest-types/src/Transform.ts b/packages/jest-types/src/Transform.ts index f303df55bdb0..52ce5162fbe2 100644 --- a/packages/jest-types/src/Transform.ts +++ b/packages/jest-types/src/Transform.ts @@ -10,16 +10,18 @@ import {Path, ProjectConfig} from './Config'; 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; - } | null; + 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; }; export type TransformResult = {