Skip to content

Commit

Permalink
feat(types): Imports
Browse files Browse the repository at this point in the history
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
  • Loading branch information
unicornware committed Dec 1, 2022
1 parent 14a69ec commit cc68844
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ const config = {
rules: {
'sort-keys': 0
}
},
{
files: ['./src/types/imports.ts'],
rules: {
'@typescript-eslint/consistent-indexed-object-style': 0
}
}
]
}
Expand Down
26 changes: 26 additions & 0 deletions src/types/__tests__/imports.spec-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* @file Unit Tests - Imports
* @module pkg-types/types/tests/Imports
*/

import type TestSubject from '../imports'

describe('unit:types/Imports', () => {
it('should allow empty object', () => {
assertType<TestSubject>({})
})

it('should allow object with ExportConditions values', () => {
assertType<TestSubject>({
'#src': { development: './src/index.ts', production: './dist/index.mjs' },
'#src/*': { development: './src/*.ts', production: './dist/*.mjs' }
})
})

it('should allow object with string values', () => {
assertType<TestSubject>({
'#src': './src/index.ts',
'#src/*': './src/*.ts'
})
})
})
17 changes: 17 additions & 0 deletions src/types/imports.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* @file Type Definitions - Imports
* @module pkg-types/types/Imports
*/

import type ExportConditions from './export-conditions'
import type ImportsKey from './imports-key'

/**
* Private mappings that only apply to import specifiers from within a
* package.
*
* @see https://nodejs.org/api/packages.html#subpath-imports
*/
type Imports = { [key: ImportsKey]: ExportConditions | string }

export type { Imports as default }
1 change: 1 addition & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export type { default as ExportConditions } from './export-conditions'
export type { default as Exports } from './exports'
export type { default as FundingType } from './funding-type'
export type { default as HoistingLimits } from './hoisiting-limits'
export type { default as Imports } from './imports'
export type { default as ImportsKey } from './imports-key'
export type { default as OS } from './os'
export type { default as Registry } from './registry'
Expand Down

0 comments on commit cc68844

Please sign in to comment.