Skip to content

Commit

Permalink
Adding Types file as dist/index.d.ts and target in package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
Julix91 committed Oct 26, 2024
1 parent 1edf345 commit 9f1d428
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
40 changes: 40 additions & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
declare module 'react-quiz-component' {
import { ReactElement } from 'react';

type QuestionType = "text" | "photo"

type AnswerSelectionType = "single" | "multiple"

type Question = {
question: string
questionType: QuestionType
answers: string[]
correctAnswer: string
answerSelectionType: AnswerSelectionType
messageForCorrectAnswer?: string
messageForIncorrectAnswer?: string
explanation?: string
point?: string
segment?: string
}

type QuizStructure = {
quizTitle: string
questions: Question[]
}

type QuizProps = {
quiz: QuizStructure;
disableSynopsis?: boolean;
shuffleAnswer?: boolean;
shuffle?: boolean;
showDefaultResult?: boolean;
showInstantFeedback?: boolean;
continueTillCorrect?: boolean;
timer?: number;
allowPauseTimer?: boolean
}

const Quiz: (props: QuizProps) => ReactElement;
export default Quiz;
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.9.1",
"description": "React Quiz Component",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"module": "dist/index.es.js",
"scripts": {
"dev": "webpack-dev-server --mode development",
Expand All @@ -24,7 +25,7 @@
"@babel/plugin-proposal-object-rest-spread": "^7.3.2",
"@babel/preset-env": "^7.3.1",
"@babel/preset-react": "^7.23.3",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plug-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^28.0.0",
"@rollup/plugin-html": "^1.0.3",
"@rollup/plugin-node-resolve": "^15.2.3",
Expand Down

0 comments on commit 9f1d428

Please sign in to comment.