Commit 3075293
committed
(refactor/types): re-write src/index.js in TypeScript
- make heavy use of the multiple iterations on types in others' PRs,
my own iterations on that, and then @types/react-signature-canvas
- credit where credit is due!
- NOTE: the naming of the props type and the class type do not include
the word "React" unlike @types/react-signature-canvas
- it is convention in React components to leave it out and you're
already importing from a package with "react" in its name
- refactor init logic a bit to get around `| null` everywhere
- kinda hacky but better than ifs or ! (non-nullable) everywhere
- use ! for canvas.getContext('2d') calls for same reason
- c.f. microsoft/TypeScript#19229
- refactor naming everywhere to src/index.tsx
- configure tsconfig -- no need for allowJs anymore, but jsx needs to
be set as TS is actually reading it now
- configure jest -- ts-jest needed to read TSX files
(deps): add DT typings for prop-types, react, and signature_pad
(deps): add a declaration file for trim-canvas as it doesn't have
types built-in yet (TODO for me!)
- use typings/ to hold external declarations1 parent 0361755 commit 3075293
File tree
8 files changed
+75
-21
lines changed- example/src
- src
- test
- typings
8 files changed
+75
-21
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| 58 | + | |
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
| 66 | + | |
| 67 | + | |
65 | 68 | | |
66 | 69 | | |
67 | 70 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
7 | 12 | | |
8 | 13 | | |
9 | 14 | | |
| |||
24 | 29 | | |
25 | 30 | | |
26 | 31 | | |
27 | | - | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
28 | 41 | | |
29 | 42 | | |
30 | 43 | | |
| |||
47 | 60 | | |
48 | 61 | | |
49 | 62 | | |
50 | | - | |
| 63 | + | |
51 | 64 | | |
52 | 65 | | |
53 | 66 | | |
54 | 67 | | |
55 | | - | |
| 68 | + | |
56 | 69 | | |
57 | 70 | | |
58 | 71 | | |
59 | 72 | | |
60 | | - | |
| 73 | + | |
61 | 74 | | |
62 | 75 | | |
63 | 76 | | |
64 | 77 | | |
65 | 78 | | |
66 | | - | |
| 79 | + | |
67 | 80 | | |
68 | 81 | | |
69 | 82 | | |
| |||
94 | 107 | | |
95 | 108 | | |
96 | 109 | | |
97 | | - | |
| 110 | + | |
98 | 111 | | |
99 | 112 | | |
100 | 113 | | |
101 | 114 | | |
102 | 115 | | |
103 | | - | |
| 116 | + | |
104 | 117 | | |
105 | 118 | | |
106 | 119 | | |
107 | 120 | | |
108 | | - | |
| 121 | + | |
109 | 122 | | |
110 | 123 | | |
111 | 124 | | |
112 | 125 | | |
113 | | - | |
| 126 | + | |
114 | 127 | | |
115 | 128 | | |
116 | 129 | | |
117 | 130 | | |
118 | | - | |
| 131 | + | |
119 | 132 | | |
120 | 133 | | |
121 | 134 | | |
122 | | - | |
| 135 | + | |
123 | 136 | | |
124 | 137 | | |
125 | 138 | | |
126 | | - | |
| 139 | + | |
127 | 140 | | |
128 | 141 | | |
129 | 142 | | |
130 | | - | |
| 143 | + | |
131 | 144 | | |
132 | 145 | | |
133 | 146 | | |
134 | | - | |
| 147 | + | |
135 | 148 | | |
136 | 149 | | |
137 | 150 | | |
138 | | - | |
| 151 | + | |
139 | 152 | | |
140 | 153 | | |
141 | 154 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
0 commit comments