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

feat(jest-resolve): expose ResolverOptions type #12736

Merged
merged 4 commits into from Apr 25, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,8 @@

### Features

- `[jest-resolve]` Expose `ResolverOptions` type ([#12736](https://github.com/facebook/jest/pull/12736))

### Fixes

### Chore & Maintenance
Expand Down
16 changes: 16 additions & 0 deletions packages/jest-resolve/__typetests__/resolver.test.ts
Expand Up @@ -12,6 +12,7 @@ import type {
PackageFilter,
PackageJSON,
PathFilter,
ResolverOptions,
SyncResolver,
} from 'jest-resolve';

Expand Down Expand Up @@ -42,6 +43,21 @@ const pathFilter = (pkg: PackageJSON, path: string, relativePath: string) =>

expectAssignable<PathFilter>(pathFilter);

// ResolverOptions

function customSyncResolver(path: string, options: ResolverOptions): string {
return path;
}
expectAssignable<SyncResolver>(customSyncResolver);

async function customAsyncResolver(
path: string,
options: ResolverOptions,
): Promise<string> {
return path;
}
expectAssignable<AsyncResolver>(customAsyncResolver);

// AsyncResolver

const asyncResolver: AsyncResolver = async (path, options) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/jest-resolve/src/defaultResolver.ts
Expand Up @@ -37,7 +37,7 @@ export type PackageFilter = (
) => PackageJSON;

/**
* Allows transforms a path within a package.
* Allows transforming a path within a package.
*
* @param pkg - Parsed `package.json` contents.
* @param path - Path being resolved.
Expand All @@ -51,7 +51,7 @@ export type PathFilter = (
relativePath: string,
) => string;

type ResolverOptions = {
export type ResolverOptions = {
/** Directory to begin resolving from. */
basedir: string;
/** List of export conditions. */
Expand Down
1 change: 1 addition & 0 deletions packages/jest-resolve/src/index.ts
Expand Up @@ -12,6 +12,7 @@ export type {
SyncResolver,
PackageFilter,
PathFilter,
ResolverOptions,
} from './defaultResolver';
export type {
FindNodeModuleConfig,
Expand Down