Skip to content

Commit

Permalink
chore: Update Typescript to 4.4.4 (excalidraw#4188)
Browse files Browse the repository at this point in the history
  • Loading branch information
lipis authored Nov 2, 2021
1 parent 60262cb commit 8d4f455
Show file tree
Hide file tree
Showing 34 changed files with 132 additions and 125 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": ["@excalidraw/eslint-config", "react-app"],
"rules": {
"import/no-anonymous-default-export": "off"
"import/no-anonymous-default-export": "off",
"no-restricted-globals": "off"
}
}
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"roughjs": "4.4.1",
"sass": "1.43.4",
"socket.io-client": "2.3.1",
"typescript": "4.2.4"
"typescript": "4.4.4"
},
"devDependencies": {
"@excalidraw/eslint-config": "1.0.0",
Expand All @@ -61,6 +61,7 @@
"@types/lodash.throttle": "4.1.6",
"@types/pako": "1.0.2",
"@types/resize-observer-browser": "0.1.6",
"@types/web": "0.0.45",
"chai": "4.3.4",
"eslint-config-prettier": "8.3.0",
"eslint-plugin-prettier": "3.3.1",
Expand All @@ -72,6 +73,9 @@
"prettier": "2.4.1",
"rewire": "5.0.0"
},
"resolutions": {
"@typescript-eslint/typescript-estree": "5.3.0"
},
"engines": {
"node": ">=14.0.0"
},
Expand Down
4 changes: 2 additions & 2 deletions scripts/autorelease.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ const publish = () => {
execSync(`yarn --frozen-lockfile`, { cwd: excalidrawDir });
execSync(`yarn run build:umd`, { cwd: excalidrawDir });
execSync(`yarn --cwd ${excalidrawDir} publish`);
} catch (e) {
console.error(e);
} catch (error) {
console.error(error);
}
};

Expand Down
4 changes: 2 additions & 2 deletions scripts/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ const release = async (nextVersion) => {
);
/* eslint-disable no-console */
console.log("Done!");
} catch (e) {
console.error(e);
} catch (error) {
console.error(error);
process.exit(1);
}
};
Expand Down
4 changes: 2 additions & 2 deletions scripts/updateChangelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ const getCommitHashForLastVersion = async () => {
`git log --format=format:"%H" --grep=${commitMessage}`,
);
return stdout;
} catch (e) {
console.error(e);
} catch (error) {
console.error(error);
}
};

Expand Down
4 changes: 2 additions & 2 deletions src/actions/actionClipboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const actionCopyAsSvg = register({
return {
commitToHistory: false,
};
} catch (error) {
} catch (error: any) {
console.error(error);
return {
appState: {
Expand Down Expand Up @@ -106,7 +106,7 @@ export const actionCopyAsPng = register({
},
commitToHistory: false,
};
} catch (error) {
} catch (error: any) {
console.error(error);
return {
appState: {
Expand Down
6 changes: 3 additions & 3 deletions src/actions/actionExport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export const actionSaveToActiveFile = register({
: null,
},
};
} catch (error) {
} catch (error: any) {
if (error?.name !== "AbortError") {
console.error(error);
}
Expand Down Expand Up @@ -181,7 +181,7 @@ export const actionSaveFileToDisk = register({
app.files,
);
return { commitToHistory: false, appState: { ...appState, fileHandle } };
} catch (error) {
} catch (error: any) {
if (error?.name !== "AbortError") {
console.error(error);
}
Expand Down Expand Up @@ -219,7 +219,7 @@ export const actionLoadScene = register({
files,
commitToHistory: true,
};
} catch (error) {
} catch (error: any) {
if (error?.name === "AbortError") {
return false;
}
Expand Down
8 changes: 4 additions & 4 deletions src/clipboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const copyToClipboard = async (
try {
PREFER_APP_CLIPBOARD = false;
await copyTextToSystemClipboard(json);
} catch (error) {
} catch (error: any) {
PREFER_APP_CLIPBOARD = true;
console.error(error);
}
Expand All @@ -87,7 +87,7 @@ const getAppClipboard = (): Partial<ElementsClipboard> => {

try {
return JSON.parse(CLIPBOARD);
} catch (error) {
} catch (error: any) {
console.error(error);
return {};
}
Expand Down Expand Up @@ -179,7 +179,7 @@ export const copyTextToSystemClipboard = async (text: string | null) => {
// not focused
await navigator.clipboard.writeText(text || "");
copied = true;
} catch (error) {
} catch (error: any) {
console.error(error);
}
}
Expand Down Expand Up @@ -219,7 +219,7 @@ const copyTextViaExecCommand = (text: string) => {
textarea.setSelectionRange(0, textarea.value.length);

success = document.execCommand("copy");
} catch (error) {
} catch (error: any) {
console.error(error);
}

Expand Down
20 changes: 10 additions & 10 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ class App extends React.Component<AppProps, AppState> {
this.onBlur();
};

private disableEvent: EventHandlerNonNull = (event) => {
private disableEvent: EventListener = (event) => {
event.preventDefault();
};

Expand Down Expand Up @@ -665,7 +665,7 @@ class App extends React.Component<AppProps, AppState> {
}
this.setState({ isLibraryOpen: true });
}
} catch (error) {
} catch (error: any) {
window.alert(t("alerts.errorLoadingLibrary"));
console.error(error);
} finally {
Expand Down Expand Up @@ -1294,8 +1294,8 @@ class App extends React.Component<AppProps, AppState> {
if ((await this.props.onPaste(data, event)) === false) {
return;
}
} catch (e) {
console.error(e);
} catch (error: any) {
console.error(error);
}
}
if (data.errorMessage) {
Expand Down Expand Up @@ -3705,7 +3705,7 @@ class App extends React.Component<AppProps, AppState> {
this.actionManager.executeAction(actionFinalize);
},
);
} catch (error) {
} catch (error: any) {
console.error(error);
this.scene.replaceAllElements(
this.scene
Expand Down Expand Up @@ -3974,7 +3974,7 @@ class App extends React.Component<AppProps, AppState> {
await normalizeSVG(await imageFile.text()),
imageFile.name,
);
} catch (error) {
} catch (error: any) {
console.warn(error);
throw new Error(t("errors.svgImageInsertError"));
}
Expand All @@ -4000,7 +4000,7 @@ class App extends React.Component<AppProps, AppState> {
imageFile,
DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT,
);
} catch (error) {
} catch (error: any) {
console.error("error trying to resing image file on insertion", error);
}

Expand Down Expand Up @@ -4061,7 +4061,7 @@ class App extends React.Component<AppProps, AppState> {
this.initializeImageDimensions(imageElement, true);
}
resolve(imageElement);
} catch (error) {
} catch (error: any) {
console.error(error);
reject(new Error(t("errors.imageInsertError")));
} finally {
Expand Down Expand Up @@ -4092,7 +4092,7 @@ class App extends React.Component<AppProps, AppState> {
imageElement,
showCursorImagePreview,
});
} catch (error) {
} catch (error: any) {
mutateElement(imageElement, {
isDeleted: true,
});
Expand Down Expand Up @@ -4187,7 +4187,7 @@ class App extends React.Component<AppProps, AppState> {
},
);
}
} catch (error) {
} catch (error: any) {
if (error.name !== "AbortError") {
console.error(error);
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/ToolButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const ToolButton = React.forwardRef((props: ToolButtonProps, ref) => {
try {
setIsLoading(true);
await ret;
} catch (error) {
} catch (error: any) {
if (!(error instanceof AbortError)) {
throw error;
}
Expand Down
6 changes: 3 additions & 3 deletions src/components/TopErrorBoundary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class TopErrorBoundary extends React.Component<
for (const [key, value] of Object.entries({ ...localStorage })) {
try {
_localStorage[key] = JSON.parse(value);
} catch (error) {
} catch (error: any) {
_localStorage[key] = value;
}
}
Expand Down Expand Up @@ -60,7 +60,7 @@ export class TopErrorBoundary extends React.Component<
)
).default;
body = encodeURIComponent(templateStrFn(this.state.sentryEventId));
} catch (error) {
} catch (error: any) {
console.error(error);
}

Expand All @@ -86,7 +86,7 @@ export class TopErrorBoundary extends React.Component<
try {
localStorage.clear();
window.location.reload();
} catch (error) {
} catch (error: any) {
console.error(error);
}
}}
Expand Down
10 changes: 5 additions & 5 deletions src/data/blob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const parseFileContents = async (blob: Blob | File) => {
return await (
await import(/* webpackChunkName: "image" */ "./image")
).decodePngMetadata(blob);
} catch (error) {
} catch (error: any) {
if (error.message === "INVALID") {
throw new DOMException(
t("alerts.imageDoesNotContainScene"),
Expand Down Expand Up @@ -58,7 +58,7 @@ const parseFileContents = async (blob: Blob | File) => {
).decodeSvgMetadata({
svg: contents,
});
} catch (error) {
} catch (error: any) {
if (error.message === "INVALID") {
throw new DOMException(
t("alerts.imageDoesNotContainScene"),
Expand Down Expand Up @@ -156,7 +156,7 @@ export const loadFromBlob = async (
);

return result;
} catch (error) {
} catch (error: any) {
console.error(error.message);
throw new Error(t("alerts.couldNotLoadInvalidFile"));
}
Expand Down Expand Up @@ -187,7 +187,7 @@ export const canvasToBlob = async (
}
resolve(blob);
});
} catch (error) {
} catch (error: any) {
reject(error);
}
});
Expand All @@ -208,7 +208,7 @@ export const generateIdFromFile = async (file: File) => {
// convert to hex string
.map((byte) => byte.toString(16).padStart(2, "0"))
.join("") as FileId;
} catch (error) {
} catch (error: any) {
console.error(error);
// length 40 to align with the HEX length of SHA-1 (which is 160 bit)
id = nanoid(40) as FileId;
Expand Down
4 changes: 2 additions & 2 deletions src/data/encode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const encode = async ({
if (compress !== false) {
try {
deflated = await toByteString(deflate(text));
} catch (error) {
} catch (error: any) {
console.error("encode: cannot deflate", error);
}
}
Expand Down Expand Up @@ -367,7 +367,7 @@ export const decompressData = async <T extends Record<string, any>>(
/** data can be anything so the caller must decode it */
data: contentsBuffer,
};
} catch (error) {
} catch (error: any) {
console.error(
`Error during decompressing and decrypting the file.`,
encodingMetadata,
Expand Down
4 changes: 2 additions & 2 deletions src/data/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const decodePngMetadata = async (blob: Blob) => {
throw new Error("FAILED");
}
return await decode(encodedData);
} catch (error) {
} catch (error: any) {
console.error(error);
throw new Error("FAILED");
}
Expand Down Expand Up @@ -127,7 +127,7 @@ export const decodeSvgMetadata = async ({ svg }: { svg: string }) => {
throw new Error("FAILED");
}
return await decode(encodedData);
} catch (error) {
} catch (error: any) {
console.error(error);
throw new Error("FAILED");
}
Expand Down
2 changes: 1 addition & 1 deletion src/data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const exportCanvas = async (
} else if (type === "clipboard") {
try {
await copyBlobToClipboardAsPng(blob);
} catch (error) {
} catch (error: any) {
if (error.name === "CANVAS_POSSIBLY_TOO_BIG") {
throw error;
}
Expand Down
4 changes: 2 additions & 2 deletions src/data/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class Library {
this.libraryCache = JSON.parse(JSON.stringify(items));

resolve(items);
} catch (error) {
} catch (error: any) {
console.error(error);
resolve([]);
}
Expand All @@ -105,7 +105,7 @@ class Library {
// immediately
this.libraryCache = JSON.parse(serializedItems);
await this.app.props.onLibraryChange?.(items);
} catch (error) {
} catch (error: any) {
this.libraryCache = prevLibraryItems;
throw error;
}
Expand Down
2 changes: 1 addition & 1 deletion src/element/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const updateImageCache = async ({
const image = await imagePromise;

imageCache.set(fileId, { ...data, image });
} catch (error) {
} catch (error: any) {
erroredFiles.set(fileId, true);
}
})(),
Expand Down
Loading

0 comments on commit 8d4f455

Please sign in to comment.