Skip to content

Commit 8afad4f

Browse files
author
ugogo
committed
fix tests and ts errors
1 parent 5b8b9c7 commit 8afad4f

File tree

4 files changed

+34
-15
lines changed

4 files changed

+34
-15
lines changed

src/index.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { ExampleComponent } from '.';
1+
import ReactInputVerificationCode from '.';
22

3-
describe('ExampleComponent', () => {
3+
describe('ReactInputVerificationCode', () => {
44
it('is truthy', () => {
5-
expect(ExampleComponent).toBeTruthy();
5+
expect(ReactInputVerificationCode).toBeTruthy();
66
});
77
});

src/index.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,15 @@ export default ({ length = 4, placeholder = '·' }) => {
9191

9292
React.useEffect(() => {
9393
const onDocumentClick = (e: MouseEvent) => {
94-
const targetIncludesContainer = e
95-
.composedPath()
96-
.reduce(
97-
(bool: boolean, path: HTMLElement) =>
98-
bool ||
99-
path.dataset?.reactInputVerificationCodeId === CONTAINER_DATA_ID,
100-
false
101-
);
94+
const targetIncludesContainer = e.composedPath().reduce(
95+
(bool: boolean, path: EventTarget) =>
96+
bool ||
97+
// @to-do: find which type to use
98+
// to make it compatible with dataset
99+
// @ts-ignore
100+
path.dataset.reactInputVerificationCodeId === CONTAINER_DATA_ID,
101+
false
102+
);
102103

103104
if (!targetIncludesContainer) setActiveIndex(-1);
104105
};

src/react-app-env.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference types="react-scripts" />

tsconfig.json

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
"compilerOptions": {
33
"outDir": "dist",
44
"module": "esnext",
5-
"lib": ["dom", "esnext"],
5+
"lib": [
6+
"dom",
7+
"esnext"
8+
],
69
"moduleResolution": "node",
710
"jsx": "react",
811
"sourceMap": true,
@@ -15,8 +18,22 @@
1518
"suppressImplicitAnyIndexErrors": true,
1619
"noUnusedLocals": true,
1720
"noUnusedParameters": true,
18-
"allowSyntheticDefaultImports": true
21+
"allowSyntheticDefaultImports": true,
22+
"target": "es5",
23+
"allowJs": true,
24+
"skipLibCheck": true,
25+
"strict": true,
26+
"forceConsistentCasingInFileNames": true,
27+
"resolveJsonModule": true,
28+
"isolatedModules": true,
29+
"noEmit": true
1930
},
20-
"include": ["src"],
21-
"exclude": ["node_modules", "dist", "example"]
31+
"include": [
32+
"src"
33+
],
34+
"exclude": [
35+
"node_modules",
36+
"dist",
37+
"example"
38+
]
2239
}

0 commit comments

Comments
 (0)