Skip to content

Commit

Permalink
feat(types): ExportCondition
Browse files Browse the repository at this point in the history
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
  • Loading branch information
unicornware committed Nov 30, 2022
1 parent 70f8c93 commit e6e4cd5
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 0 deletions.
56 changes: 56 additions & 0 deletions src/types/__tests__/export-condition.spec-d.ts
Original file line number Diff line number Diff line change
@@ -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<TestSubject>('browser')
})

it('should allow "default"', () => {
assertType<TestSubject>('default')
})

it('should allow "deno"', () => {
assertType<TestSubject>('deno')
})

it('should allow "development"', () => {
assertType<TestSubject>('development')
})

it('should allow "electron"', () => {
assertType<TestSubject>('electron')
})

it('should allow "import"', () => {
assertType<TestSubject>('import')
})

it('should allow "node-addons"', () => {
assertType<TestSubject>('node-addons')
})

it('should allow "node"', () => {
assertType<TestSubject>('node')
})

it('should allow "production"', () => {
assertType<TestSubject>('production')
})

it('should allow "react-native"', () => {
assertType<TestSubject>('react-native')
})

it('should allow "require"', () => {
assertType<TestSubject>('require')
})

it('should allow "types"', () => {
assertType<TestSubject>('types')
})
})
29 changes: 29 additions & 0 deletions src/types/export-condition.ts
Original file line number Diff line number Diff line change
@@ -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 }
1 change: 1 addition & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit e6e4cd5

Please sign in to comment.