Skip to content

Commit b54dbbb

Browse files
committed
feat: ExportsSubpath
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
1 parent 0c70854 commit b54dbbb

File tree

6 files changed

+41
-10
lines changed

6 files changed

+41
-10
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ import type {
8383
- [`ExportsKey`](./src/exports-key.ts)
8484
- [`ExportsList`](./src/exports-list.ts)
8585
- [`ExportsObject`](./src/exports-object.ts)
86+
- [`ExportsSubpath`](./src/exports-subpath.ts)
8687
- [`ImportConditions`](./src/import-conditions.ts)
8788
- [`Imports`](./src/imports.ts)
8889
- [`ImportsKey`](./src/imports-key.ts)

src/__tests__/exports-key.spec-d.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,14 @@
55

66
import type Condition from '../condition'
77
import type TestSubject from '../exports-key'
8+
import type ExportsSubpath from '../exports-subpath'
89

910
describe('unit-d:ExportsKey', () => {
10-
it('should extract "."', () => {
11-
expectTypeOf<TestSubject>().extract<'.'>().not.toBeNever()
12-
})
13-
14-
it('should extract `./${string}`', () => {
15-
expectTypeOf<TestSubject>().extract<`./${string}`>().not.toBeNever()
16-
})
17-
1811
it('should extract Condition', () => {
1912
expectTypeOf<TestSubject>().extract<Condition>().not.toBeNever()
2013
})
14+
15+
it('should extract ExportsSubpath', () => {
16+
expectTypeOf<TestSubject>().extract<ExportsSubpath>().not.toBeNever()
17+
})
2118
})
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* @file Unit Tests - ExportsSubpath
3+
* @module pkg-types/tests/unit-d/ExportsSubpath
4+
*/
5+
6+
import type TestSubject from '../exports-subpath'
7+
8+
describe('unit-d:ExportsSubpath', () => {
9+
it('should extract "."', () => {
10+
expectTypeOf<TestSubject>().extract<'.'>().not.toBeNever()
11+
})
12+
13+
it('should extract `./${string}`', () => {
14+
expectTypeOf<TestSubject>().extract<`./${string}`>().not.toBeNever()
15+
})
16+
})

src/exports-key.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@
44
*/
55

66
import type Condition from './condition'
7+
import type ExportsSubpath from './exports-subpath'
78

89
/**
910
* An `exports` object key.
1011
*
11-
* @see https://nodejs.org/api/packages.html#subpath-exports
12+
* @see {@linkcode Condition}
13+
* @see {@linkcode ExportsSubpath}
14+
* @see https://nodejs.org/api/packages.html#package-entry-points
1215
*/
13-
type ExportsKey = '.' | `./${string}` | Condition
16+
type ExportsKey = Condition | ExportsSubpath
1417

1518
export type { ExportsKey as default }

src/exports-subpath.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* @file ExportsSubpath
3+
* @module pkg-types/ExportsSubpath
4+
*/
5+
6+
/**
7+
* A subpath `exports` object key.
8+
*
9+
* @see https://nodejs.org/api/packages.html#subpath-exports
10+
*/
11+
type ExportsSubpath = '.' | `./${string}`
12+
13+
export type { ExportsSubpath as default }

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export type { default as Exports } from './exports'
2525
export type { default as ExportsKey } from './exports-key'
2626
export type { default as ExportsList } from './exports-list'
2727
export type { default as ExportsObject } from './exports-object'
28+
export type { default as ExportsSubpath } from './exports-subpath'
2829
export type { default as ImportConditions } from './import-conditions'
2930
export type { default as Imports } from './imports'
3031
export type { default as ImportsKey } from './imports-key'

0 commit comments

Comments
 (0)