Skip to content

Commit d1ee708

Browse files
committed
Fix various incompatibilities.
1 parent dcc8f8b commit d1ee708

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

src/all.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import './style.scss';
2-
import { JSON, JsonObject, JsonProperty } from "ta-json";
32
import { render, Component } from 'inferno';
43
import { PreviewSign } from './view_preview';
54
import { Sign, PaperSize } from './data';
@@ -36,8 +35,7 @@ interface SignWithID {
3635
sign: Sign;
3736
id: number;
3837
}
39-
export class App extends Component {
40-
state : { signs: SignWithID[], visible_signs: SignWithID[]};
38+
export class App extends Component<{}, { signs: SignWithID[], visible_signs: SignWithID[]}>{
4139

4240
constructor(props: any) {
4341
super(props);

src/main.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import './style.scss';
2-
import { JSON, JsonObject, JsonProperty } from "ta-json";
2+
import { JSON } from "ta-json";
33
import { render, Component } from 'inferno';
44
import { PreviewSign } from './view_preview';
55
import { Sign } from './data';
@@ -34,7 +34,7 @@ function SignItem({ item, onOpen }: any) {
3434
)
3535
}
3636

37-
class SignSelector extends Component {
37+
class SignSelector extends Component<any, {signs: Sign[] }> {
3838
constructor(props: any) {
3939
super(props);
4040
this.state = { signs: [] }
@@ -94,7 +94,7 @@ class SignSelectorSmall extends SignSelector {
9494
// How often to save (at most). In milliseconds
9595
const SavingInterval = 2000;
9696

97-
export class App extends Component {
97+
export class App extends Component<any, { sign: Sign | null, id: number | null }> {
9898
saving: boolean;
9999
debouncedSave = debounce(() => this.save(), SavingInterval);
100100

src/view_preview.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ accessMessage[Access.CourseRequired] = "You must complete a course to use this m
107107
accessMessage[Access.UsableByEveryone] = "All members may use this machine";
108108
accessMessage[Access.UsableByEveryoneCareful] = "You may use this machine if you know how to operate it and can do so safely";
109109

110-
class CourseQRCode extends Component {
110+
class CourseQRCode extends Component<{ sign: Sign }, { qrData: string }> {
111111
state: any;
112112
lastQRUrl: string = null;
113113

@@ -136,7 +136,9 @@ class CourseQRCode extends Component {
136136
}
137137
}
138138

139-
QRCode.toDataURL(url, opts).then(data => {
139+
QRCode.toDataURL(url, opts, (e, data) => {
140+
// Hack: required when called from constructor
141+
this.state.qrData = data;
140142
this.setState({ qrData: data });
141143
});
142144
}
@@ -191,8 +193,7 @@ const SignOutOfOrder = ({sign}: {sign: Sign}) => {
191193
);
192194
}
193195

194-
class PreviewSignFooter extends Component {
195-
state: any;
196+
class PreviewSignFooter extends Component<{ sign: Sign, id: number }, { qrData: string }> {
196197
lastQRUrl: string = null;
197198

198199
constructor(props: any) {
@@ -220,13 +221,17 @@ class PreviewSignFooter extends Component {
220221
}
221222
}
222223

223-
QRCode.toDataURL(url, opts).then(data => {
224+
console.log("URL ", url);
225+
QRCode.toDataURL(url, opts, (e, data) => {
226+
// Hack: required when called from constructor
227+
this.state.qrData = data;
224228
this.setState({ qrData: data });
225229
});
226230
}
227231
}
228232

229233
render() {
234+
console.log("Q", this.state.qrData);
230235
return (
231236
<Fragment>
232237
<div class="sign-footer">

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"target": "es5",
77
"jsx": "preserve",
88
"allowJs": true,
9+
"moduleResolution": "node",
910
"experimentalDecorators": true,
1011
"types": [
1112
"inferno"

0 commit comments

Comments
 (0)