Skip to content

Commit a8ec9be

Browse files
committed
Adding Types file as lib/react-quiz-component.d.ts and target in package.json
1 parent 1edf345 commit a8ec9be

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "0.9.1",
44
"description": "React Quiz Component",
55
"main": "dist/index.js",
6+
"types": "lib/react-quiz-component.d.ts",
67
"module": "dist/index.es.js",
78
"scripts": {
89
"dev": "webpack-dev-server --mode development",

src/lib/react-quiz-component.d.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
declare module 'react-quiz-component' {
2+
import { ReactElement } from 'react';
3+
4+
type QuestionType = "text" | "photo"
5+
6+
type AnswerSelectionType = "single" | "multiple"
7+
8+
type Question = {
9+
question: string
10+
questionType: QuestionType
11+
answers: string[]
12+
correctAnswer: string
13+
answerSelectionType: AnswerSelectionType
14+
messageForCorrectAnswer?: string
15+
messageForIncorrectAnswer?: string
16+
explanation?: string
17+
point?: string
18+
segment?: string
19+
}
20+
21+
type QuizStructure = {
22+
quizTitle: string
23+
questions: Question[]
24+
}
25+
26+
type QuizProps = {
27+
quiz: QuizStructure;
28+
disableSynopsis?: boolean;
29+
shuffleAnswer?: boolean;
30+
shuffle?: boolean;
31+
showDefaultResult?: boolean;
32+
showInstantFeedback?: boolean;
33+
continueTillCorrect?: boolean;
34+
timer?: number;
35+
allowPauseTimer?: boolean
36+
}
37+
38+
const Quiz: (props: QuizProps) => ReactElement;
39+
export default Quiz;
40+
}

0 commit comments

Comments
 (0)