diff --git a/src/types/__tests__/export-condition.spec-d.ts b/src/types/__tests__/export-condition.spec-d.ts new file mode 100644 index 00000000..5a833a7f --- /dev/null +++ b/src/types/__tests__/export-condition.spec-d.ts @@ -0,0 +1,56 @@ +/** + * @file Unit Tests - ExportCondition + * @module pkg-types/types/tests/ExportCondition + */ + +import type TestSubject from '../export-condition' + +describe('unit:types/ExportCondition', () => { + it('should allow "browser"', () => { + assertType('browser') + }) + + it('should allow "default"', () => { + assertType('default') + }) + + it('should allow "deno"', () => { + assertType('deno') + }) + + it('should allow "development"', () => { + assertType('development') + }) + + it('should allow "electron"', () => { + assertType('electron') + }) + + it('should allow "import"', () => { + assertType('import') + }) + + it('should allow "node-addons"', () => { + assertType('node-addons') + }) + + it('should allow "node"', () => { + assertType('node') + }) + + it('should allow "production"', () => { + assertType('production') + }) + + it('should allow "react-native"', () => { + assertType('react-native') + }) + + it('should allow "require"', () => { + assertType('require') + }) + + it('should allow "types"', () => { + assertType('types') + }) +}) diff --git a/src/types/export-condition.ts b/src/types/export-condition.ts new file mode 100644 index 00000000..20e96c97 --- /dev/null +++ b/src/types/export-condition.ts @@ -0,0 +1,29 @@ +/** + * @file Type Definitions - ExportCondition + * @module pkg-types/types/ExportCondition + */ + +import type { LiteralUnion } from '@flex-development/tutils' + +/** + * Conditions indicating how to resolve a package entry point. + * + * @see https://nodejs.org/api/packages.html#conditional-exports + */ +type ExportCondition = LiteralUnion< + | 'browser' + | 'default' + | 'deno' + | 'development' + | 'electron' + | 'import' + | 'node-addons' + | 'node' + | 'production' + | 'react-native' + | 'require' + | 'types', + string +> + +export type { ExportCondition as default } diff --git a/src/types/index.ts b/src/types/index.ts index 0f939ad0..205cc0dd 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -6,6 +6,7 @@ export type { default as Access } from './access' export type { default as CPU } from './cpu' export type { default as Engine } from './engine' +export type { default as ExportCondition } from './export-condition' export type { default as HoistingLimits } from './hoisiting-limits' export type { default as Registry } from './registry' export type { default as Type } from './type'