diff --git a/CHANGELOG.md b/CHANGELOG.md index 112157a8e4d5..c11c78045dae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ ### Chore & Maintenance +- `[@jest/transform]` Expose type `TransformedSource` ([#9736](https://github.com/facebook/jest/pull/9736)) + ### Performance ## 25.2.4 @@ -17,7 +19,7 @@ ### Fixes - `[jest-circus]` Fix type elision of jest-runtime imports ([#9717](https://github.com/facebook/jest/pull/9717)) -- `[@jest/transform]` Fix coverage reporter for uncovered files without transformers, reverting ([#9460](https://github.com/facebook/jest/pull/9460)) ([#9724](https://github.com/facebook/jest/pull/9724)) +- `[@jest/transform]` Fix coverage reporter for uncovered files without transformers, reverting [#9460](https://github.com/facebook/jest/pull/9460) ([#9724](https://github.com/facebook/jest/pull/9724)) ## 25.2.3 diff --git a/packages/jest-transform/src/index.ts b/packages/jest-transform/src/index.ts index 48bd4a688248..ada1dd88716e 100644 --- a/packages/jest-transform/src/index.ts +++ b/packages/jest-transform/src/index.ts @@ -15,5 +15,6 @@ export type { ShouldInstrumentOptions, Options as TransformationOptions, TransformResult, + TransformedSource, } from './types'; export {default as handlePotentialSyntaxError} from './enhanceUnexpectedTokenMessage'; diff --git a/packages/jest-transform/src/types.ts b/packages/jest-transform/src/types.ts index a826105e2630..9cf2716dbfee 100644 --- a/packages/jest-transform/src/types.ts +++ b/packages/jest-transform/src/types.ts @@ -32,10 +32,9 @@ interface FixedRawSourceMap extends SourceMapWithVersion { version: number; } -export type TransformedSource = { - code: string; - map?: FixedRawSourceMap | string | null; -}; +export type TransformedSource = + | {code: string; map?: FixedRawSourceMap | string | null} + | string; export type TransformResult = { code: string; @@ -70,5 +69,5 @@ export interface Transformer { sourcePath: Config.Path, config: Config.ProjectConfig, options?: TransformOptions, - ) => string | TransformedSource; + ) => TransformedSource; }