From ca58cfa5c8cb81c763ceadee8bd11942d85b22cc Mon Sep 17 00:00:00 2001 From: Hikari Hayashi Date: Tue, 2 Jul 2024 22:36:45 +0800 Subject: [PATCH] fix: update the return type of `createCacheKey` --- CHANGELOG.md | 1 + packages/jest-create-cache-key-function/src/index.ts | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ccaacd976b9..a08a0e839ca0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -59,6 +59,7 @@ - `[jest-config]` Support `coverageReporters` in project config ([#14697](https://github.com/jestjs/jest/pull/14830)) - `[jest-config]` Allow `reporters` in project config ([#14768](https://github.com/jestjs/jest/pull/14768)) - `[jest-config]` Allow Node16/NodeNext/Bundler `moduleResolution` in project's tsconfig ([#14739](https://github.com/jestjs/jest/pull/14739)) +- `[@jest/create-cache-key-function]` Correct the return type of `createCacheKey` ([#15159](https://github.com/jestjs/jest/pull/15159)) - `[jest-each]` Allow `$keypath` templates with `null` or `undefined` values ([#14831](https://github.com/jestjs/jest/pull/14831)) - `[@jest/expect-utils]` Fix comparison of `DataView` ([#14408](https://github.com/jestjs/jest/pull/14408)) - `[@jest/expect-utils]` [**BREAKING**] exclude non-enumerable in object matching ([#14670](https://github.com/jestjs/jest/pull/14670)) diff --git a/packages/jest-create-cache-key-function/src/index.ts b/packages/jest-create-cache-key-function/src/index.ts index 0fdc6285cfaa..e750a048f71d 100644 --- a/packages/jest-create-cache-key-function/src/index.ts +++ b/packages/jest-create-cache-key-function/src/index.ts @@ -38,7 +38,7 @@ type NewGetCacheKeyFunction = ( options: NewCacheKeyOptions, ) => string; -type GetCacheKeyFunction = OldGetCacheKeyFunction | NewGetCacheKeyFunction; +type GetCacheKeyFunction = OldGetCacheKeyFunction & NewGetCacheKeyFunction; const {NODE_ENV, BABEL_ENV} = process.env; @@ -65,7 +65,7 @@ function getCacheKeyFunction( globalCacheKey: string, length: number, ): GetCacheKeyFunction { - return (sourceText, sourcePath, configString, options) => { + return ((sourceText, sourcePath, configString, options) => { // Jest 27 passes a single options bag which contains `configString` rather than as a separate argument. // We can hide that API difference, though, so this module is usable for both jest@<27 and jest@>=27 const inferredOptions = options || configString; @@ -81,7 +81,7 @@ function getCacheKeyFunction( .update(instrument ? 'instrument' : '') .digest('hex') .slice(0, length); - }; + }) as GetCacheKeyFunction; } /**