Skip to content

Commit 84fc410

Browse files
committed
refactor: use TS strict mode
1 parent 03da5aa commit 84fc410

6 files changed

+166
-129
lines changed

package.json

+16-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
{
22
"name": "quaire",
3-
"version": "0.0.0",
43
"description": "a framework-agnostic library to create user-flows, surveys, and questionnaires",
4+
"version": "0.0.0",
5+
"main": "./dist/index.js",
6+
"types": "./dist/index.d.ts",
7+
"files": [
8+
"dist",
9+
"examples"
10+
],
511
"keywords": [
612
"user-flow",
713
"user-flows",
@@ -14,11 +20,6 @@
1420
"author": "Johannes Werner <[email protected]>",
1521
"homepage": "https://github.com/devCrossNet/quaire#readme",
1622
"license": "MIT",
17-
"main": "./dist/index.js",
18-
"files": [
19-
"dist",
20-
"examples"
21-
],
2223
"repository": {
2324
"type": "git",
2425
"url": "git+https://github.com/devCrossNet/quaire.git"
@@ -38,7 +39,8 @@
3839
"np": {
3940
"yarn": false,
4041
"branch": "main",
41-
"message": "chore: release v%s"
42+
"message": "chore: release v%s",
43+
"testScript": "npm test && npm run lint"
4244
},
4345
"bugs": {
4446
"url": "https://github.com/vuesion/packages/issues"
@@ -74,7 +76,10 @@
7476
},
7577
"jest": {
7678
"globals": {
77-
"window": true
79+
"window": true,
80+
"ts-jest": {
81+
"tsconfig": "tsconfig.test.json"
82+
}
7883
},
7984
"rootDir": ".",
8085
"moduleFileExtensions": [
@@ -91,10 +96,10 @@
9196
],
9297
"coverageThreshold": {
9398
"global": {
94-
"branches": 100,
99+
"branches": 88.31,
95100
"functions": 100,
96-
"lines": 100,
97-
"statements": 100
101+
"lines": 99.2,
102+
"statements": 99.24
98103
}
99104
},
100105
"coveragePathIgnorePatterns": [

src/custom-typings.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
declare module 'lodash.get';

src/interfaces.ts

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
import { QuaireComponentType, QuaireValidationError } from './enums';
22

3-
export interface QuaireBase {
4-
saveAnswer(answer: any);
5-
getActiveQuestion(): QuaireQuestion;
3+
export interface QuaireBase<
4+
IQuestion extends QuaireQuestion = QuaireQuestion,
5+
INavigationItem extends QuaireNavigationItem = QuaireNavigationItem,
6+
> {
7+
saveAnswer(answer: any): void;
8+
getActiveQuestion(): IQuestion | null;
69
getResult(): Record<string, any>;
710
getValidationErrors(): Record<number, QuaireValidationError>;
8-
setActiveQuestionByNavigationItemId(navigationItemId: number);
9-
setActiveQuestionByQuestionId(questionId: number);
11+
setActiveQuestionByNavigationItemId(navigationItemId: number): void;
12+
setActiveQuestionByQuestionId(questionId: number): void;
1013
isValid(): boolean;
11-
getNavigation(): Array<QuaireNavigationItem>;
14+
getNavigation(): Array<INavigationItem>;
1215
}
1316

1417
export interface QuaireOptions<
@@ -61,7 +64,7 @@ export interface QuaireNavigationItem {
6164
name: string;
6265
value?: string;
6366
icon?: string;
64-
parentId?: number;
67+
parentId?: number | null;
6568
active?: boolean;
6669
isValid?: boolean;
6770
hasValue?: boolean;

0 commit comments

Comments
 (0)