Skip to content

Commit f5150fd

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

File tree

4 files changed

+63
-0
lines changed

4 files changed

+63
-0
lines changed

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

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"{@linkcode PackageJson}": "https://github.com/flex-development/pkg-types/blob/2.0.0/src/interfaces/package-json.ts",
2323
"{@linkcode PackageScope}": "/api/interfaces/#packagescope",
2424
"{@linkcode ParseModuleIdOptions}": "/api/interfaces/#parsemoduleidoptions",
25+
"{@linkcode ParseSubpathOptions}": "/api/interfaces/#parsesubpathoptions",
2526
"{@linkcode ParsedModuleId}": "/api/interfaces/#parsedmoduleid",
2627
"{@linkcode Protocol}": "/api/types#protocol",
2728
"{@linkcode RESOLVE_EXTENSIONS}": "/api/#resolve-extensions",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* @file Type Tests - ParseSubpathOptions
3+
* @module mlly/interfaces/tests/unit-d/ParseSubpathOptions
4+
*/
5+
6+
import type { ModuleId } from '#src/types'
7+
import type TestSubject from '../options-parse-subpath'
8+
9+
describe('unit-d:interfaces/ParseSubpathOptions', () => {
10+
it('should match [dir: ModuleId]', () => {
11+
expectTypeOf<TestSubject>().toHaveProperty('dir').toEqualTypeOf<ModuleId>()
12+
})
13+
14+
it('should match [internal?: boolean]', () => {
15+
expectTypeOf<TestSubject>()
16+
.toHaveProperty('internal')
17+
.toEqualTypeOf<boolean | undefined>()
18+
})
19+
20+
it('should match [parent: ModuleId]', () => {
21+
expectTypeOf<TestSubject>()
22+
.toHaveProperty('parent')
23+
.toEqualTypeOf<ModuleId>()
24+
})
25+
})

src/interfaces/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export type { default as StaticImport } from './import-static'
99
export type { default as GetFormatOptions } from './options-get-format'
1010
export type { default as GetSourceOptions } from './options-get-source'
1111
export type { default as ParseModuleIdOptions } from './options-parse-module-id'
12+
export type { default as ParseSubpathOptions } from './options-parse-subpath'
1213
export type { default as ResolveOptions } from './options-resolve'
1314
export type { default as ResolveAliasOptions } from './options-resolve-alias'
1415
export type { default as PackageScope } from './package-scope'
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* @file Interfaces - ParseSubpathOptions
3+
* @module mlly/interfaces/ParseSubpathOptions
4+
*/
5+
6+
import type { ModuleId } from '#src/types'
7+
8+
/**
9+
* Subpath parsing options.
10+
*
11+
* @see {@linkcode ModuleId}
12+
*/
13+
interface ParseSubpathOptions {
14+
/**
15+
* URL of directory containing relevant `package.json` file.
16+
*/
17+
dir: ModuleId
18+
19+
/**
20+
* Package [`imports`][1] hint.
21+
*
22+
* [1]: https://nodejs.org/api/packages.html#imports
23+
*
24+
* @default specifier.startsWith('#')
25+
*/
26+
internal?: boolean | undefined
27+
28+
/**
29+
* URL of module to resolve from.
30+
*
31+
* **Note**: Used for error reporting only.
32+
*/
33+
parent: ModuleId
34+
}
35+
36+
export type { ParseSubpathOptions as default }

0 commit comments

Comments
 (0)