Skip to content

Commit a4ac43a

Browse files
committed
feat(types): Question
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
1 parent c55d596 commit a4ac43a

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
lines changed
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* @file Type Tests - Question
3+
* @module commitlint-config/types/tests/unit-d/Question
4+
*/
5+
6+
import type TestSubject from '../question'
7+
import type QuestionEnum from '../question-enum'
8+
9+
describe('unit-d:types/Question', () => {
10+
it('should match [description: string]', () => {
11+
expectTypeOf<TestSubject>().toHaveProperty('description').toBeString()
12+
})
13+
14+
it('should match [enum?: { [key in N]: Q }]', () => {
15+
expectTypeOf<TestSubject>()
16+
.toHaveProperty('enum')
17+
.toEqualTypeOf<{ [key in string]: QuestionEnum } | undefined>()
18+
})
19+
20+
it('should match [messages?: { [key in string]: string }]', () => {
21+
expectTypeOf<TestSubject>()
22+
.toHaveProperty('messages')
23+
.toEqualTypeOf<{ [key in string]: string } | undefined>()
24+
})
25+
})

src/types/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
*/
55

66
export type { default as NoteKeyword } from './note-keyword'
7+
export type { default as Question } from './question'
78
export type { default as QuestionEnum } from './question-enum'

src/types/question.ts

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* @file Type Definitions - Question
3+
* @module commitlint-config/types/Question
4+
*/
5+
6+
import type QuestionEnum from './question-enum'
7+
8+
/**
9+
* Object representing a prompt question.
10+
*
11+
* @see https://commitlint.js.org/#/reference-prompt?id=questions
12+
*
13+
* @template N - Question enum names
14+
* @template Q - Question enum type
15+
*/
16+
type Question<
17+
N extends string = string,
18+
Q extends QuestionEnum = QuestionEnum
19+
> = {
20+
/**
21+
* Question description.
22+
*/
23+
description: string
24+
25+
/**
26+
* Question enums.
27+
*/
28+
enum?: { [key in N]: Q }
29+
30+
/**
31+
* Message hints.
32+
*/
33+
messages?: { [key in string]: string }
34+
}
35+
36+
export type { Question as default }

0 commit comments

Comments
 (0)