diff --git a/package.json b/package.json index c91069ec..c50a962c 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "roughjs": "4.3.1", "sass": "1.32.8", "socket.io-client": "2.3.1", - "typescript": "4.1.5" + "typescript": "4.2.3" }, "devDependencies": { "@excalidraw/eslint-config": "1.0.0", diff --git a/src/components/App.tsx b/src/components/App.tsx index efd03b96..dfb77b31 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -532,18 +532,22 @@ class App extends React.Component { } this.setState( - (state) => ({ - ...actionResult.appState, - editingElement: - editingElement || actionResult.appState?.editingElement || null, - width: state.width, - height: state.height, - offsetTop: state.offsetTop, - offsetLeft: state.offsetLeft, - viewModeEnabled, - zenModeEnabled, - gridSize, - }), + (state) => { + // using Object.assign instead of spread to fool TS 4.2.2+ into + // regarding the resulting type as not containing undefined + // (which the following expression will never contain) + return Object.assign(actionResult.appState || {}, { + editingElement: + editingElement || actionResult.appState?.editingElement || null, + width: state.width, + height: state.height, + offsetTop: state.offsetTop, + offsetLeft: state.offsetLeft, + viewModeEnabled, + zenModeEnabled, + gridSize, + }); + }, () => { if (actionResult.syncHistory) { history.setCurrentState( diff --git a/yarn.lock b/yarn.lock index 63869ea9..eada685a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13967,10 +13967,10 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= -typescript@4.1.5: - version "4.1.5" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.1.5.tgz#123a3b214aaff3be32926f0d8f1f6e704eb89a72" - integrity sha512-6OSu9PTIzmn9TCDiovULTnET6BgXtDYL4Gg4szY+cGsc3JP1dQL8qvE8kShTRx1NIw4Q9IBHlwODjkjWEtMUyA== +typescript@4.2.3: + version "4.2.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.2.3.tgz#39062d8019912d43726298f09493d598048c1ce3" + integrity sha512-qOcYwxaByStAWrBf4x0fibwZvMRG+r4cQoTjbPtUlrWjBHbmCAww1i448U0GJ+3cNNEtebDteo/cHOR3xJ4wEw== unicode-canonical-property-names-ecmascript@^1.0.4: version "1.0.4"