Skip to content

Commit

Permalink
feat: ExportsSubpath
Browse files Browse the repository at this point in the history
Signed-off-by: Lexus Drumgold <[email protected]>
  • Loading branch information
unicornware committed Sep 1, 2024
1 parent 0c70854 commit b54dbbb
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 10 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ import type {
- [`ExportsKey`](./src/exports-key.ts)
- [`ExportsList`](./src/exports-list.ts)
- [`ExportsObject`](./src/exports-object.ts)
- [`ExportsSubpath`](./src/exports-subpath.ts)
- [`ImportConditions`](./src/import-conditions.ts)
- [`Imports`](./src/imports.ts)
- [`ImportsKey`](./src/imports-key.ts)
Expand Down
13 changes: 5 additions & 8 deletions src/__tests__/exports-key.spec-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,14 @@

import type Condition from '../condition'
import type TestSubject from '../exports-key'
import type ExportsSubpath from '../exports-subpath'

describe('unit-d:ExportsKey', () => {
it('should extract "."', () => {
expectTypeOf<TestSubject>().extract<'.'>().not.toBeNever()
})

it('should extract `./${string}`', () => {
expectTypeOf<TestSubject>().extract<`./${string}`>().not.toBeNever()
})

it('should extract Condition', () => {
expectTypeOf<TestSubject>().extract<Condition>().not.toBeNever()
})

it('should extract ExportsSubpath', () => {
expectTypeOf<TestSubject>().extract<ExportsSubpath>().not.toBeNever()
})
})
16 changes: 16 additions & 0 deletions src/__tests__/exports-subpath.spec-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* @file Unit Tests - ExportsSubpath
* @module pkg-types/tests/unit-d/ExportsSubpath
*/

import type TestSubject from '../exports-subpath'

describe('unit-d:ExportsSubpath', () => {
it('should extract "."', () => {
expectTypeOf<TestSubject>().extract<'.'>().not.toBeNever()
})

it('should extract `./${string}`', () => {
expectTypeOf<TestSubject>().extract<`./${string}`>().not.toBeNever()
})
})
7 changes: 5 additions & 2 deletions src/exports-key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
*/

import type Condition from './condition'
import type ExportsSubpath from './exports-subpath'

/**
* An `exports` object key.
*
* @see https://nodejs.org/api/packages.html#subpath-exports
* @see {@linkcode Condition}
* @see {@linkcode ExportsSubpath}
* @see https://nodejs.org/api/packages.html#package-entry-points
*/
type ExportsKey = '.' | `./${string}` | Condition
type ExportsKey = Condition | ExportsSubpath

export type { ExportsKey as default }
13 changes: 13 additions & 0 deletions src/exports-subpath.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* @file ExportsSubpath
* @module pkg-types/ExportsSubpath
*/

/**
* A subpath `exports` object key.
*
* @see https://nodejs.org/api/packages.html#subpath-exports
*/
type ExportsSubpath = '.' | `./${string}`

export type { ExportsSubpath as default }
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export type { default as Exports } from './exports'
export type { default as ExportsKey } from './exports-key'
export type { default as ExportsList } from './exports-list'
export type { default as ExportsObject } from './exports-object'
export type { default as ExportsSubpath } from './exports-subpath'
export type { default as ImportConditions } from './import-conditions'
export type { default as Imports } from './imports'
export type { default as ImportsKey } from './imports-key'
Expand Down

0 comments on commit b54dbbb

Please sign in to comment.