Skip to content

Commit

Permalink
refactor(types): update exports type
Browse files Browse the repository at this point in the history
  • Loading branch information
kwaa committed Sep 18, 2024
1 parent 0209bb2 commit 0b308db
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/types/src/patch/exports.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
import type { XOR } from '../lib/xor'

interface Export {
[k: string]: Export | string | undefined
default?: Export | string
import?: Export | string
require?: Export | string
types?: Export | string
}

interface TopLevelExport extends Record<`./${string}`, Export | string | undefined> {
'.'?: Export | string
'./package.json'?: './package.json'
}

/**
* The "exports" field is used to restrict external access to non-exported module files, also enables a module to import itself using "name".
*/
export type Exports = null | XOR<Record<string, unknown>, `./${string}`, `./${string}`[]>
export type Exports = null | XOR<XOR<TopLevelExport, Export>, `./${string}`, `./${string}`[]>

0 comments on commit 0b308db

Please sign in to comment.