From cfb324a6d58671db7595df4b74d14a2e1291b357 Mon Sep 17 00:00:00 2001 From: Aria Minaei Date: Tue, 8 Aug 2023 08:43:24 +0200 Subject: [PATCH] Upgrade typescript --- examples/basic-dom/package.json | 2 +- package.json | 2 +- packages/benchmarks/package.json | 2 +- packages/browser-bundles/package.json | 2 +- packages/dataverse-experiments/package.json | 2 +- packages/dataverse/package.json | 2 +- packages/dataverse/src/dataverse.test.ts | 2 +- packages/dataverse/src/prism/prism.ts | 2 +- packages/playground/package.json | 2 +- packages/r3f/package.json | 2 +- packages/react/package.json | 2 +- packages/theatric/package.json | 2 +- theatre/package.json | 2 +- .../shared/src/_logger/logger.test-helpers.ts | 2 +- .../shared/src/utils/deepMergeWithCache.ts | 6 ++- theatre/shared/src/utils/minimalOverride.ts | 2 +- .../createTransactionPrivateApi.ts | 4 +- theatre/studio/src/css.tsx | 2 +- theatre/studio/src/store/stateEditors.ts | 3 +- theatre/studio/src/utils/derive-utils.tsx | 4 +- .../studio/src/utils/redux/configureStore.ts | 6 ++- .../src/utils/renderInPortalInContext.tsx | 2 +- tsconfig.base.json | 1 - yarn.lock | 40 ++++++++++++------- 24 files changed, 57 insertions(+), 41 deletions(-) diff --git a/examples/basic-dom/package.json b/examples/basic-dom/package.json index 76347e5..95a283d 100644 --- a/examples/basic-dom/package.json +++ b/examples/basic-dom/package.json @@ -11,6 +11,6 @@ "parcel-bundler": "^1.12.5", "react": "^17.0.2", "react-dom": "^17.0.2", - "typescript": "4.6.4" + "typescript": "5.1.6" } } diff --git a/package.json b/package.json index d83c9f9..109c019 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "lint-staged": "^13.0.3", "node-gyp": "^9.1.0", "prettier": "^2.3.2", - "typescript": "4.6.4", + "typescript": "5.1.6", "yaml": "^2.3.1" }, "packageManager": "yarn@3.2.0", diff --git a/packages/benchmarks/package.json b/packages/benchmarks/package.json index af792c3..a7d65bb 100644 --- a/packages/benchmarks/package.json +++ b/packages/benchmarks/package.json @@ -25,6 +25,6 @@ "@types/react": "^18.0.25", "esbuild": "^0.15.15", "esbuild-register": "^3.4.1", - "typescript": "4.6.4" + "typescript": "5.1.6" } } diff --git a/packages/browser-bundles/package.json b/packages/browser-bundles/package.json index a06a2ca..1116857 100644 --- a/packages/browser-bundles/package.json +++ b/packages/browser-bundles/package.json @@ -25,7 +25,7 @@ "esbuild": "^0.12.15", "esbuild-register": "^2.5.0", "npm-run-all": "^4.1.5", - "typescript": "4.6.4" + "typescript": "5.1.6" }, "peerDependencies": { "@theatre/core": "*", diff --git a/packages/dataverse-experiments/package.json b/packages/dataverse-experiments/package.json index b092add..c309709 100644 --- a/packages/dataverse-experiments/package.json +++ b/packages/dataverse-experiments/package.json @@ -18,7 +18,7 @@ "@types/lodash-es": "^4.17.4", "@types/node": "^15.6.2", "@types/react": "^17.0.9", - "typescript": "4.6.4" + "typescript": "5.1.6" }, "dependencies": { "lodash-es": "^4.17.21" diff --git a/packages/dataverse/package.json b/packages/dataverse/package.json index d524ffb..931a360 100644 --- a/packages/dataverse/package.json +++ b/packages/dataverse/package.json @@ -35,7 +35,7 @@ "esbuild": "^0.12.15", "esbuild-register": "^2.5.0", "npm-run-all": "^4.1.5", - "typescript": "4.6.4" + "typescript": "5.1.6" }, "dependencies": { "lodash-es": "^4.17.21" diff --git a/packages/dataverse/src/dataverse.test.ts b/packages/dataverse/src/dataverse.test.ts index 3d719f8..079174e 100644 --- a/packages/dataverse/src/dataverse.test.ts +++ b/packages/dataverse/src/dataverse.test.ts @@ -696,7 +696,7 @@ describe(`The exhaustive guide to dataverse`, () => { // Let's create a function that will set a property of an object by a pointer, similar to `lodash.set()`. // The function will take the root object, the pointer, and the new value. - function setByPointer( + function setByPointer( root: Root, getPointer: (ptr: Pointer) => Pointer, newValue: Value, diff --git a/packages/dataverse/src/prism/prism.ts b/packages/dataverse/src/prism/prism.ts index 856547b..bed9c3e 100644 --- a/packages/dataverse/src/prism/prism.ts +++ b/packages/dataverse/src/prism/prism.ts @@ -233,7 +233,7 @@ class PrismInstance implements Prism { } // let's cache the last value so we don't call the listener if the value hasn't changed - let lastValue = + let lastValue: V | typeof emptyObject = // use an empty object as the initial value so that the listener is called on the first tick. // if we were to use, say, undefined, and this.getValue() also returned undefined, the listener // would never be called. diff --git a/packages/playground/package.json b/packages/playground/package.json index 4dc4e97..550aa0d 100644 --- a/packages/playground/package.json +++ b/packages/playground/package.json @@ -39,7 +39,7 @@ "styled-components": "^5.3.11", "theatric": "workspace:*", "three": "^0.155.0", - "typescript": "4.6.4", + "typescript": "5.1.6", "vite": "^4.3.9" } } diff --git a/packages/r3f/package.json b/packages/r3f/package.json index 9393a2b..cd31bfa 100644 --- a/packages/r3f/package.json +++ b/packages/r3f/package.json @@ -73,7 +73,7 @@ "styled-components": "^5.3.11", "three": "0.155.0", "three-stdlib": "^2.24.1", - "typescript": "4.6.4", + "typescript": "5.1.6", "zustand": "^3.5.1" }, "peerDependencies": { diff --git a/packages/react/package.json b/packages/react/package.json index 02eface..dacfcc7 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -37,7 +37,7 @@ "esbuild": "^0.12.15", "esbuild-register": "^2.5.0", "npm-run-all": "^4.1.5", - "typescript": "4.6.4" + "typescript": "5.1.6" }, "dependencies": { "@theatre/dataverse": "workspace:*", diff --git a/packages/theatric/package.json b/packages/theatric/package.json index c67e65b..5d74302 100644 --- a/packages/theatric/package.json +++ b/packages/theatric/package.json @@ -37,7 +37,7 @@ "esbuild-register": "^2.5.0", "lodash-es": "^4.17.21", "npm-run-all": "^4.1.5", - "typescript": "4.6.4" + "typescript": "5.1.6" }, "dependencies": { "@theatre/core": "workspace:*", diff --git a/theatre/package.json b/theatre/package.json index 75714b0..cf90b7c 100644 --- a/theatre/package.json +++ b/theatre/package.json @@ -82,7 +82,7 @@ "shallowequal": "^1.1.0", "styled-components": "^5.3.11", "timing-function": "^0.2.3", - "typescript": "4.6.4", + "typescript": "5.1.6", "uuid": "^8.3.2" }, "dependencies": { diff --git a/theatre/shared/src/_logger/logger.test-helpers.ts b/theatre/shared/src/_logger/logger.test-helpers.ts index 4b42063..1262eae 100644 --- a/theatre/shared/src/_logger/logger.test-helpers.ts +++ b/theatre/shared/src/_logger/logger.test-helpers.ts @@ -129,7 +129,7 @@ function expectLastCalledWith( } } -function objMap( +function objMap( template: T, eachEntry:

(entry: [name: P, value: T[P]]) => U, ): {[P in keyof T]: U} { diff --git a/theatre/shared/src/utils/deepMergeWithCache.ts b/theatre/shared/src/utils/deepMergeWithCache.ts index a859ecf..935150c 100644 --- a/theatre/shared/src/utils/deepMergeWithCache.ts +++ b/theatre/shared/src/utils/deepMergeWithCache.ts @@ -72,7 +72,11 @@ export default function deepMergeWithCache( // @ts-ignore @todo merged[key] = typeof valueInOverride === 'object' && typeof valueInBase === 'object' - ? deepMergeWithCache(valueInBase, valueInOverride, cache) + ? deepMergeWithCache( + valueInBase as SerializableMap, + valueInOverride, + cache, + ) : valueInOverride === undefined ? valueInBase : valueInOverride diff --git a/theatre/shared/src/utils/minimalOverride.ts b/theatre/shared/src/utils/minimalOverride.ts index 758d746..5b89256 100644 --- a/theatre/shared/src/utils/minimalOverride.ts +++ b/theatre/shared/src/utils/minimalOverride.ts @@ -60,7 +60,7 @@ function typeOfValue(v: unknown): ValueType { * }) * ``` */ -export default function minimalOverride(base: T, override: T): T { +export default function minimalOverride(base: T, override: T): T { const typeofOverride = typeOfValue(override) if (typeofOverride === ValueType.Opaque) { return override diff --git a/theatre/studio/src/StudioStore/createTransactionPrivateApi.ts b/theatre/studio/src/StudioStore/createTransactionPrivateApi.ts index 9639b70..4126d13 100644 --- a/theatre/studio/src/StudioStore/createTransactionPrivateApi.ts +++ b/theatre/studio/src/StudioStore/createTransactionPrivateApi.ts @@ -35,7 +35,7 @@ function cloneDeepSerializableAndPrune(v: T): T | undefined { } else if (isPlainObject(v)) { const cloned: $IntentionalAny = {} let clonedAtLeastOneProp = false - for (const [key, val] of Object.entries(v)) { + for (const [key, val] of Object.entries(v as {})) { const clonedVal = cloneDeepSerializableAndPrune(val) if (clonedVal !== undefined) { cloned[key] = val @@ -169,7 +169,7 @@ export default function createTransactionPrivateApi( const pathToPropInProvidedValue = pathToProp.slice(lengthOfTopPointer) - const v = getDeep(_value, pathToPropInProvidedValue) + const v = getDeep(_value as {}, pathToPropInProvidedValue) if (typeof v !== 'undefined') { setStaticOrKeyframeProp(v, primitivePropConfig, pathToProp) } else { diff --git a/theatre/studio/src/css.tsx b/theatre/studio/src/css.tsx index 302f114..0b441c6 100644 --- a/theatre/studio/src/css.tsx +++ b/theatre/studio/src/css.tsx @@ -95,7 +95,7 @@ export const ProvideStyles: React.FC<{ ) } -export function withStyledShadow( +export function withStyledShadow( Comp: React.ComponentType, ): React.ComponentType { return (props) => ( diff --git a/theatre/studio/src/store/stateEditors.ts b/theatre/studio/src/store/stateEditors.ts index 528cf66..6fa9414 100644 --- a/theatre/studio/src/store/stateEditors.ts +++ b/theatre/studio/src/store/stateEditors.ts @@ -32,6 +32,7 @@ import type { IRange, SerializableMap, SerializablePrimitive, + SerializableValue, } from '@theatre/shared/utils/types' import {current} from 'immer' import findLastIndex from 'lodash-es/findLastIndex' @@ -773,7 +774,7 @@ namespace stateEditors { * Sets a keyframe at the exact specified position. * Any position snapping should be done by the caller. */ - export function setKeyframeAtPosition( + export function setKeyframeAtPosition( p: WithoutSheetInstance & { trackId: SequenceTrackId position: number diff --git a/theatre/studio/src/utils/derive-utils.tsx b/theatre/studio/src/utils/derive-utils.tsx index f185f8a..a62720f 100644 --- a/theatre/studio/src/utils/derive-utils.tsx +++ b/theatre/studio/src/utils/derive-utils.tsx @@ -1,7 +1,7 @@ import {isPrism, prism, val} from '@theatre/dataverse' import type {Prism, Pointer} from '@theatre/dataverse' import {usePrismInstance} from '@theatre/react' -import type {$IntentionalAny} from '@theatre/shared/utils/types' +import type {$FixMe, $IntentionalAny} from '@theatre/shared/utils/types' import React, {useMemo, useRef} from 'react' import {invariant} from './invariant' @@ -100,5 +100,5 @@ export function deriver( finalComp.displayName = `deriver(${Component.displayName})` - return finalComp + return finalComp as $FixMe } diff --git a/theatre/studio/src/utils/redux/configureStore.ts b/theatre/studio/src/utils/redux/configureStore.ts index fbe46cd..c5d7f6f 100644 --- a/theatre/studio/src/utils/redux/configureStore.ts +++ b/theatre/studio/src/utils/redux/configureStore.ts @@ -7,12 +7,14 @@ import identity from 'lodash-es/identity' import type {Store} from 'redux' import {compose, createStore} from 'redux' -interface Conf { +interface Conf { rootReducer: ReduxReducer devtoolsOptions?: $FixMe } -export default function configureStore(conf: Conf): Store { +export default function configureStore( + conf: Conf, +): Store { // const middlewares: $FixMe[] = [] const enhancers = [] diff --git a/theatre/studio/src/utils/renderInPortalInContext.tsx b/theatre/studio/src/utils/renderInPortalInContext.tsx index 7bce0c7..40b3664 100644 --- a/theatre/studio/src/utils/renderInPortalInContext.tsx +++ b/theatre/studio/src/utils/renderInPortalInContext.tsx @@ -22,7 +22,7 @@ let lastId = 1 export const getMounter = () => { const id = lastId++ - function mountOrRender( + function mountOrRender( comp: React.ComponentType, props: Props, portalNode: HTMLElement, diff --git a/tsconfig.base.json b/tsconfig.base.json index d595248..c84b17b 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -8,7 +8,6 @@ "target": "ESNext", "lib": ["es2017", "dom", "ESNext"], "isolatedModules": true, - "importsNotUsedAsValues": "error", "noFallthroughCasesInSwitch": true, "jsx": "react", "skipLibCheck": true, diff --git a/yarn.lock b/yarn.lock index 06e518e..3c9d0e4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5672,7 +5672,7 @@ __metadata: parcel-bundler: ^1.12.5 react: ^17.0.2 react-dom: ^17.0.2 - typescript: 4.6.4 + typescript: 5.1.6 languageName: unknown linkType: soft @@ -7670,7 +7670,7 @@ __metadata: esbuild: ^0.12.15 esbuild-register: ^2.5.0 npm-run-all: ^4.1.5 - typescript: 4.6.4 + typescript: 5.1.6 peerDependencies: "@theatre/core": "*" "@theatre/studio": "*" @@ -7729,7 +7729,7 @@ __metadata: "@types/node": ^15.6.2 "@types/react": ^17.0.9 lodash-es: ^4.17.21 - typescript: 4.6.4 + typescript: 5.1.6 languageName: unknown linkType: soft @@ -7745,7 +7745,7 @@ __metadata: esbuild-register: ^2.5.0 lodash-es: ^4.17.21 npm-run-all: ^4.1.5 - typescript: 4.6.4 + typescript: 5.1.6 languageName: unknown linkType: soft @@ -7779,7 +7779,7 @@ __metadata: styled-components: ^5.3.11 three: 0.155.0 three-stdlib: ^2.24.1 - typescript: 4.6.4 + typescript: 5.1.6 zustand: ^3.5.1 peerDependencies: "@react-three/fiber": ^8.13.6 @@ -7807,7 +7807,7 @@ __metadata: lodash-es: ^4.17.21 npm-run-all: ^4.1.5 queue-microtask: ^1.2.3 - typescript: 4.6.4 + typescript: 5.1.6 peerDependencies: react: "*" react-dom: "*" @@ -11438,7 +11438,7 @@ __metadata: "@types/react": ^18.0.25 esbuild: ^0.15.15 esbuild-register: ^3.4.1 - typescript: 4.6.4 + typescript: 5.1.6 languageName: unknown linkType: soft @@ -25055,7 +25055,7 @@ fsevents@^1.2.7: styled-components: ^5.3.11 theatric: "workspace:*" three: ^0.155.0 - typescript: 4.6.4 + typescript: 5.1.6 vite: ^4.3.9 languageName: unknown linkType: soft @@ -31180,7 +31180,7 @@ fsevents@^1.2.7: lint-staged: ^13.0.3 node-gyp: ^9.1.0 prettier: ^2.3.2 - typescript: 4.6.4 + typescript: 5.1.6 yaml: ^2.3.1 languageName: unknown linkType: soft @@ -31253,7 +31253,7 @@ fsevents@^1.2.7: shallowequal: ^1.1.0 styled-components: ^5.3.11 timing-function: ^0.2.3 - typescript: 4.6.4 + typescript: 5.1.6 uuid: ^8.3.2 languageName: unknown linkType: soft @@ -31274,7 +31274,7 @@ fsevents@^1.2.7: esbuild-register: ^2.5.0 lodash-es: ^4.17.21 npm-run-all: ^4.1.5 - typescript: 4.6.4 + typescript: 5.1.6 peerDependencies: react: "*" languageName: unknown @@ -31973,13 +31973,13 @@ fsevents@^1.2.7: languageName: node linkType: hard -"typescript@npm:4.6.4, typescript@npm:~4.6.3": - version: 4.6.4 - resolution: "typescript@npm:4.6.4" +"typescript@npm:5.1.6": + version: 5.1.6 + resolution: "typescript@npm:5.1.6" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: e7bfcc39cd4571a63a54e5ea21f16b8445268b9900bf55aee0e02ad981be576acc140eba24f1af5e3c1457767c96cea6d12861768fb386cf3ffb34013718631a + checksum: b2f2c35096035fe1f5facd1e38922ccb8558996331405eb00a5111cc948b2e733163cc22fab5db46992aba7dd520fff637f2c1df4996ff0e134e77d3249a7350 languageName: node linkType: hard @@ -31993,6 +31993,16 @@ fsevents@^1.2.7: languageName: node linkType: hard +"typescript@npm:~4.6.3": + version: 4.6.4 + resolution: "typescript@npm:4.6.4" + bin: + tsc: bin/tsc + tsserver: bin/tsserver + checksum: e7bfcc39cd4571a63a54e5ea21f16b8445268b9900bf55aee0e02ad981be576acc140eba24f1af5e3c1457767c96cea6d12861768fb386cf3ffb34013718631a + languageName: node + linkType: hard + "uglify-js@npm:^3.1.4": version: 3.15.5 resolution: "uglify-js@npm:3.15.5"