Skip to content

Commit b5fd706

Browse files
committed
feat(interfaces): FindSubpathOptions
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
1 parent 8479781 commit b5fd706

File tree

4 files changed

+95
-0
lines changed

4 files changed

+95
-0
lines changed

docs/.vitepress/theme/comments/link-replacements.json

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"{@linkcode ExportStatement}": "/api/interfaces#exportstatement",
1212
"{@linkcode Exports}": "https://github.com/flex-development/pkg-types/blob/2.0.0/src/types/exports.ts",
1313
"{@linkcode Ext}": "https://github.com/flex-development/pathe/blob/main/src/types/ext.ts",
14+
"{@linkcode FindSubpathOptions}": "/api/interfaces#findsubpathoptions",
1415
"{@linkcode Format}": "/api/enums#format",
1516
"{@linkcode GetFormatOptions}": "/api/interfaces#getformatoptions",
1617
"{@linkcode GetSourceOptions}": "/api/interfaces#getsourceoptions",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* @file Type Tests - FindSubpathOptions
3+
* @module mlly/interfaces/tests/unit-d/FindSubpathOptions
4+
*/
5+
6+
import type { ModuleId } from '#src/types'
7+
import type TestSubject from '../options-find-subpath'
8+
9+
describe('unit-d:interfaces/FindSubpathOptions', () => {
10+
it('should match [condition?: string]', () => {
11+
expectTypeOf<TestSubject>()
12+
.toHaveProperty('condition')
13+
.toEqualTypeOf<string | undefined>()
14+
})
15+
16+
it('should match [conditions?: Set<string>]', () => {
17+
expectTypeOf<TestSubject>()
18+
.toHaveProperty('conditions')
19+
.toEqualTypeOf<Set<string> | undefined>()
20+
})
21+
22+
it('should match [dir: ModuleId]', () => {
23+
expectTypeOf<TestSubject>().toHaveProperty('dir').toEqualTypeOf<ModuleId>()
24+
})
25+
26+
it('should match [internal?: boolean]', () => {
27+
expectTypeOf<TestSubject>()
28+
.toHaveProperty('internal')
29+
.toEqualTypeOf<boolean | undefined>()
30+
})
31+
32+
it('should match [parent: ModuleId]', () => {
33+
expectTypeOf<TestSubject>()
34+
.toHaveProperty('parent')
35+
.toEqualTypeOf<ModuleId>()
36+
})
37+
})

src/interfaces/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
export type { default as ImportAssertions } from './import-assertions'
77
export type { default as DynamicImport } from './import-dynamic'
88
export type { default as StaticImport } from './import-static'
9+
export type { default as FindSubpathOptions } from './options-find-subpath'
910
export type { default as GetFormatOptions } from './options-get-format'
1011
export type { default as GetSourceOptions } from './options-get-source'
1112
export type { default as ParseModuleIdOptions } from './options-parse-module-id'
+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/**
2+
* @file Interfaces - FindSubpathOptions
3+
* @module mlly/interfaces/FindSubpathOptions
4+
*/
5+
6+
import type { ModuleId } from '#src/types'
7+
8+
/**
9+
* Subpath search options.
10+
*
11+
* @see {@linkcode ModuleId}
12+
*/
13+
interface FindSubpathOptions {
14+
/**
15+
* Export condition to apply.
16+
*
17+
* @see https://nodejs.org/api/packages.html#conditional-exports
18+
*
19+
* @default 'default'
20+
*/
21+
condition?: string | undefined
22+
23+
/**
24+
* Export conditions.
25+
*
26+
* **Note**: Should be sorted by priority.
27+
*
28+
* @see https://nodejs.org/api/packages.html#conditional-exports
29+
*
30+
* @default CONDITIONS
31+
*/
32+
conditions?: Set<string> | undefined
33+
34+
/**
35+
* URL of directory containing relevant `package.json` file.
36+
*/
37+
dir: ModuleId
38+
39+
/**
40+
* Package [`imports`][1] hint.
41+
*
42+
* [1]: https://nodejs.org/api/packages.html#imports
43+
*
44+
* @default false
45+
*/
46+
internal?: boolean | undefined
47+
48+
/**
49+
* URL of module to resolve from.
50+
*
51+
* **Note**: Used for error reporting only.
52+
*/
53+
parent: ModuleId
54+
}
55+
56+
export type { FindSubpathOptions as default }

0 commit comments

Comments
 (0)