Skip to content

Commit 1bed527

Browse files
committed
fix(types): incorrect and unfinished NodeResolverOptions typing
1 parent ec4b277 commit 1bed527

File tree

3 files changed

+41
-6
lines changed

3 files changed

+41
-6
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
"yarn-berry-deduplicate": "^6.1.3"
101101
},
102102
"resolutions": {
103+
"eslint-import-context": "link:.",
103104
"prettier": "^3.5.3"
104105
},
105106
"typeCoverage": {

src/types.ts

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,44 @@ export type Resolver = LegacyResolver | NewResolver
3737

3838
export type ResolvedResult = ResultFound | ResultNotFound
3939

40-
export interface NodeResolverOptions {
41-
extensions?: readonly string[]
42-
moduleDirectory?: string[]
43-
paths?: string[]
40+
export interface NodeResolverOptions
41+
extends Omit<NapiResolveOptions, 'extensions'> {
42+
/** Directory to begin resolving from (defaults to __dirname) */
43+
basedir?: string
44+
/** Set to false to exclude node core modules (e.g. fs) from the search */
45+
includeCoreModules?: boolean
46+
/** Array of file extensions to search in order (defaults to ['.js']) */
47+
extensions?: string | readonly string[]
48+
/**
49+
* Require.paths array to use if nothing is found on the normal node_modules
50+
* recursive walk (probably don't use this)
51+
*/
52+
paths?: string | readonly string[]
53+
/**
54+
* Directory (or directories) in which to recursively look for modules.
55+
* (default to 'node_modules')
56+
*/
57+
moduleDirectory?: string | readonly string[]
58+
/**
59+
* If true, doesn't resolve `basedir` to real path before resolving. This is
60+
* the way Node resolves dependencies when executed with the
61+
* --preserve-symlinks flag.
62+
*
63+
* Note: this property is currently true by default but it will be changed to
64+
* false in the next major version because Node's resolution algorithm does
65+
* not preserve symlinks by default.
66+
*/
67+
preserveSymlinks?: boolean
68+
69+
// The following options are not supported anymore, but kept for compatibility
70+
/** @deprecated */
71+
package?: unknown
72+
/** @deprecated */
73+
packageFilter?: unknown
74+
/** @deprecated */
75+
pathFilter?: unknown
76+
/** @deprecated */
77+
packageIterator?: unknown
4478
}
4579

4680
export interface WebpackResolverOptions {
@@ -65,7 +99,7 @@ export type LegacyResolverResolveImport<T = unknown> = (
6599
modulePath: string,
66100
sourceFile: string,
67101
config: T,
68-
) => string | undefined
102+
) => string
69103

70104
export type LegacyResolverResolve<T = unknown> = (
71105
modulePath: string,

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7323,7 +7323,7 @@ __metadata:
73237323
languageName: node
73247324
linkType: soft
73257325

7326-
"eslint-import-context@npm:^0.1.3, eslint-import-context@npm:^0.1.4, eslint-import-context@workspace:.":
7326+
"eslint-import-context@workspace:.":
73277327
version: 0.0.0-use.local
73287328
resolution: "eslint-import-context@workspace:."
73297329
dependencies:

0 commit comments

Comments
 (0)