Skip to content

Commit

Permalink
feat(jest-resolve): expose ResolverOptions type (jestjs#12736)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrazauskas authored and F3n67u committed May 2, 2022
1 parent 3378d86 commit b6e3f7d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
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

0 comments on commit b6e3f7d

Please sign in to comment.