diff --git a/src/types/__tests__/dependency-map.spec-d.ts b/src/types/__tests__/dependency-map.spec-d.ts new file mode 100644 index 00000000..fd45ac75 --- /dev/null +++ b/src/types/__tests__/dependency-map.spec-d.ts @@ -0,0 +1,41 @@ +/** + * @file Unit Tests - DependencyMap + * @module pkg-types/types/tests/DependencyMap + */ + +import type { DependencyMeta, PeerDependencyMeta } from '#src/interfaces' +import pkg from '../../../package.json' assert { type: 'json' } +import type TestSubject from '../dependency-map' + +describe('unit:types/DependencyMap', () => { + it('should allow dependency map', () => { + assertType>(pkg.devDependencies) + }) + + it('should allow dependency for browsers', () => { + assertType>({ + fs: false, + path: './dist/browser-shims/path.mjs' + }) + }) + + it('should allow dependency metadata map', () => { + assertType>({ + fsevents: { built: false, optional: false, unplugged: true } + }) + }) + + it('should allow peer dependency metadata map', () => { + assertType>({ + '@flex-development/tutils': { optional: false } + }) + }) + + it('should allow empty object', () => { + // Arrange + type T = DependencyMeta | PeerDependencyMeta | string | false + + // Expect + assertType>({}) + }) +}) diff --git a/src/types/dependency-map.ts b/src/types/dependency-map.ts new file mode 100644 index 00000000..988e2305 --- /dev/null +++ b/src/types/dependency-map.ts @@ -0,0 +1,17 @@ +/** + * @file Type Definitions - DependencyMap + * @module pkg-types/types/DependencyMap + */ + +import type { DependencyMeta, PeerDependencyMeta } from '#src/interfaces' + +/** + * Maps dependency names to version ranges, files, or metadata. + * + * @template T - Version range, file, or metadata type + */ +type DependencyMap< + T extends DependencyMeta | PeerDependencyMeta | string | false +> = Partial> + +export type { DependencyMap as default } diff --git a/src/types/index.ts b/src/types/index.ts index fedd3f00..36d0768a 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -5,6 +5,7 @@ export type { default as Access } from './access' export type { default as CPU } from './cpu' +export type { default as DependencyMap } from './dependency-map' export type { default as Engine } from './engine' export type { default as ExportCondition } from './export-condition' export type { default as FundingType } from './funding-type'