Skip to content

Commit 9c11549

Browse files
authored
fix: update the return type of createCacheKey (#15159)
1 parent 19bf1cd commit 9c11549

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
- `[jest-config]` Support `coverageReporters` in project config ([#14697](https://github.com/jestjs/jest/pull/14830))
6363
- `[jest-config]` Allow `reporters` in project config ([#14768](https://github.com/jestjs/jest/pull/14768))
6464
- `[jest-config]` Allow Node16/NodeNext/Bundler `moduleResolution` in project's tsconfig ([#14739](https://github.com/jestjs/jest/pull/14739))
65+
- `[@jest/create-cache-key-function]` Correct the return type of `createCacheKey` ([#15159](https://github.com/jestjs/jest/pull/15159))
6566
- `[jest-each]` Allow `$keypath` templates with `null` or `undefined` values ([#14831](https://github.com/jestjs/jest/pull/14831))
6667
- `[@jest/expect-utils]` Fix comparison of `DataView` ([#14408](https://github.com/jestjs/jest/pull/14408))
6768
- `[@jest/expect-utils]` [**BREAKING**] exclude non-enumerable in object matching ([#14670](https://github.com/jestjs/jest/pull/14670))

packages/jest-create-cache-key-function/src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ type NewGetCacheKeyFunction = (
3838
options: NewCacheKeyOptions,
3939
) => string;
4040

41-
type GetCacheKeyFunction = OldGetCacheKeyFunction | NewGetCacheKeyFunction;
41+
type GetCacheKeyFunction = OldGetCacheKeyFunction & NewGetCacheKeyFunction;
4242

4343
const {NODE_ENV, BABEL_ENV} = process.env;
4444

@@ -65,7 +65,7 @@ function getCacheKeyFunction(
6565
globalCacheKey: string,
6666
length: number,
6767
): GetCacheKeyFunction {
68-
return (sourceText, sourcePath, configString, options) => {
68+
return ((sourceText, sourcePath, configString, options) => {
6969
// Jest 27 passes a single options bag which contains `configString` rather than as a separate argument.
7070
// We can hide that API difference, though, so this module is usable for both jest@<27 and jest@>=27
7171
const inferredOptions = options || configString;
@@ -81,7 +81,7 @@ function getCacheKeyFunction(
8181
.update(instrument ? 'instrument' : '')
8282
.digest('hex')
8383
.slice(0, length);
84-
};
84+
}) as GetCacheKeyFunction;
8585
}
8686

8787
/**

0 commit comments

Comments
 (0)