Skip to content

Commit 97ee265

Browse files
committed
feat(interfaces): ParseModuleIdOptions
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
1 parent a536567 commit 97ee265

File tree

4 files changed

+72
-0
lines changed

4 files changed

+72
-0
lines changed

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

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"{@linkcode NodeError}": "https://github.com/flex-development/errnode/blob/1.2.0/src/types/node-error.ts",
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",
24+
"{@linkcode ParsedModuleIdOptions}": "/api/interfaces/#parsedmoduleidoptions",
2425
"{@linkcode Protocol}": "/api/types#protocol",
2526
"{@linkcode RESOLVE_EXTENSIONS}": "/api/#resolve-extensions",
2627
"{@linkcode RequestInit}": "https://github.com/node-fetch/node-fetch/blob/v3.3.0/@types/index.d.ts#L71-L112",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* @file Type Tests - ParseModuleIdOptions
3+
* @module mlly/interfaces/tests/unit-d/ParseModuleIdOptions
4+
*/
5+
6+
import type { ModuleId } from '#src/types'
7+
import type { KeysRequired } from '@flex-development/tutils'
8+
import type TestSubject from '../options-parse-module-id'
9+
10+
describe('unit-d:interfaces/ParseModuleIdOptions', () => {
11+
it('should allow empty object', () => {
12+
expectTypeOf<KeysRequired<TestSubject>>().toBeNever()
13+
})
14+
15+
it('should match [internal?: boolean]', () => {
16+
expectTypeOf<TestSubject>()
17+
.toHaveProperty('internal')
18+
.toEqualTypeOf<boolean | undefined>()
19+
})
20+
21+
it('should match [parent?: ModuleId]', () => {
22+
expectTypeOf<TestSubject>()
23+
.toHaveProperty('parent')
24+
.toEqualTypeOf<ModuleId | undefined>()
25+
})
26+
27+
it('should match [pkgname?: boolean]', () => {
28+
expectTypeOf<TestSubject>()
29+
.toHaveProperty('pkgname')
30+
.toEqualTypeOf<boolean | undefined>()
31+
})
32+
})

src/interfaces/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export type { default as DynamicImport } from './import-dynamic'
88
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'
11+
export type { default as ParseModuleIdOptions } from './options-parse-module-id'
1112
export type { default as ResolveOptions } from './options-resolve'
1213
export type { default as ResolveAliasOptions } from './options-resolve-alias'
1314
export type { default as PackageScope } from './package-scope'
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* @file Interfaces - ParseModuleIdOptions
3+
* @module mlly/interfaces/ParseModuleIdOptions
4+
*/
5+
6+
import type { ModuleId } from '#src/types'
7+
8+
/**
9+
* Module id parsing options.
10+
*
11+
* @see {@linkcode ModuleId}
12+
*/
13+
interface ParseModuleIdOptions {
14+
/**
15+
* Ensure module id is a valid internal specifier, syntactically.
16+
*
17+
* @see https://nodejs.org/api/packages.html#subpath-imports
18+
*
19+
* @default id instanceof URL ? false : id.startsWith('#')
20+
*/
21+
internal?: boolean | undefined
22+
23+
/**
24+
* URL of module to resolve from.
25+
*
26+
* **Note**: Used for error reporting only.
27+
*
28+
* @default undefined
29+
*/
30+
parent?: ModuleId | undefined
31+
32+
/**
33+
* Ensure module id begins with a valid package name.
34+
*/
35+
pkgname?: boolean | undefined
36+
}
37+
38+
export type { ParseModuleIdOptions as default }

0 commit comments

Comments
 (0)