Skip to content

Commit 6873ad8

Browse files
committed
feat(interfaces): ImportAssertions
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
1 parent 607469f commit 6873ad8

File tree

4 files changed

+55
-0
lines changed

4 files changed

+55
-0
lines changed

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
*/
55

66
export * from './enums'
7+
export * from './interfaces'
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* @file Type Tests - ImportAssertions
3+
* @module esm-types/interfaces/tests/unit-d/ImportAssertions
4+
*/
5+
6+
import type { AssertType } from '#src/enums'
7+
import type { LiteralUnion } from '@flex-development/tutils'
8+
import type TestSubject from '../import-assertions'
9+
10+
describe('unit-d:interfaces/ImportAssertions', () => {
11+
it('should allow empty object', () => {
12+
assertType<TestSubject>({})
13+
})
14+
15+
it('should allow only string values', () => {
16+
expectTypeOf<TestSubject[string]>().toBeString()
17+
})
18+
19+
it('should match [type?: LiteralUnion<AssertType, string>]', () => {
20+
expectTypeOf<TestSubject>()
21+
.toHaveProperty('type')
22+
.toEqualTypeOf<LiteralUnion<AssertType, string> | undefined>()
23+
})
24+
})

src/interfaces/import-assertions.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* @file Interfaces - ImportAssertions
3+
* @module esm-types/interfaces/ImportAssertions
4+
*/
5+
6+
import type { AssertType } from '#src/enums'
7+
import type { LiteralUnion } from '@flex-development/tutils'
8+
9+
/**
10+
* `import` assertions schema.
11+
*
12+
* @see {@linkcode AssertType}
13+
* @see https://github.com/tc39/proposal-import-assertions
14+
*/
15+
interface ImportAssertions {
16+
[key: string]: string
17+
18+
/**
19+
* Assertion type.
20+
*/
21+
type?: LiteralUnion<AssertType, string>
22+
}
23+
24+
export type { ImportAssertions as default }

src/interfaces/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/**
2+
* @file Entry Point - Interfaces
3+
* @module esm-types/interfaces
4+
*/
5+
6+
export type { default as ImportAssertions } from './import-assertions'

0 commit comments

Comments
 (0)