Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update the return type of createCacheKey #15159

Merged
merged 1 commit into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
6 changes: 3 additions & 3 deletions packages/jest-create-cache-key-function/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type NewGetCacheKeyFunction = (
options: NewCacheKeyOptions,
) => string;

type GetCacheKeyFunction = OldGetCacheKeyFunction | NewGetCacheKeyFunction;
type GetCacheKeyFunction = OldGetCacheKeyFunction & NewGetCacheKeyFunction;

const {NODE_ENV, BABEL_ENV} = process.env;

Expand All @@ -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;
Expand All @@ -81,7 +81,7 @@ function getCacheKeyFunction(
.update(instrument ? 'instrument' : '')
.digest('hex')
.slice(0, length);
};
}) as GetCacheKeyFunction;
}

/**
Expand Down
Loading