Skip to content

Make images smaller using best-in-class codecs, right in the browser.

JavaScript

Fix typings for TypeScript v3.2

Surma9746a9f5eddd
diff --git a/src/components/App/index.tsx b/src/components/App/index.tsx
index f30ddc7c..962d72bd 100644
--- a/src/components/App/index.tsx
+++ b/src/components/App/index.tsx
@@ -56,8 +56,8 @@ export default class App extends Component<Props, State> {
if (process.env.NODE_ENV === 'development') {
this.setState(window.STATE);
const oldCDU = this.componentDidUpdate;
- this.componentDidUpdate = (props, state) => {
- if (oldCDU) oldCDU.call(this, props, state);
+ this.componentDidUpdate = (props, state, prev) => {
+ if (oldCDU) oldCDU.call(this, props, state, prev);
window.STATE = this.state;
};
}
diff --git a/src/components/Options/index.tsx b/src/components/Options/index.tsx
index 98783a07..5d2b1d31 100644
--- a/src/components/Options/index.tsx
+++ b/src/components/Options/index.tsx
@@ -40,7 +40,9 @@ import Checkbox from '../checkbox';
import Expander from '../expander';
import Select from '../select';
-const encoderOptionsComponentMap = {
+const encoderOptionsComponentMap: {
+ [x: string]: (new (...args: any[]) => Component<any, any>) | undefined;
+} = {
[identity.type]: undefined,
[optiPNG.type]: OptiPNGEncoderOptions,
[mozJPEG.type]: MozJpegEncoderOptions,
diff --git a/src/components/compress/index.tsx b/src/components/compress/index.tsx
index af631030..2bb90f03 100644
--- a/src/components/compress/index.tsx
+++ b/src/components/compress/index.tsx
@@ -576,9 +576,9 @@ export default class Compress extends Component<Props, State> {
mobileView={mobileView}
preprocessorState={side.latestSettings.preprocessorState}
encoderState={side.latestSettings.encoderState}
- onEncoderTypeChange={this.onEncoderTypeChange.bind(this, index)}
- onEncoderOptionsChange={this.onEncoderOptionsChange.bind(this, index)}
- onPreprocessorOptionsChange={this.onPreprocessorOptionsChange.bind(this, index)}
+ onEncoderTypeChange={this.onEncoderTypeChange.bind(this, index as 0|1)}
+ onEncoderOptionsChange={this.onEncoderOptionsChange.bind(this, index as 0|1)}
+ onPreprocessorOptionsChange={this.onPreprocessorOptionsChange.bind(this, index as 0|1)}
/>
));
@@ -592,7 +592,7 @@ export default class Compress extends Component<Props, State> {
source={source}
loading={loading || side.loading}
copyDirection={copyDirections[index]}
- onCopyToOtherClick={this.onCopyToOtherClick.bind(this, index)}
+ onCopyToOtherClick={this.onCopyToOtherClick.bind(this, index as 0|1)}
buttonPosition={mobileView ? 'stack-right' : buttonPositions[index]}
>
{!mobileView ? null : [