Upgrade typescript

This commit is contained in:
Aria Minaei 2023-08-08 08:43:24 +02:00
parent cb6693413f
commit cfb324a6d5
24 changed files with 57 additions and 41 deletions

View file

@ -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"
}
}

View file

@ -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",

View file

@ -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"
}
}

View file

@ -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": "*",

View file

@ -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"

View file

@ -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"

View file

@ -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<Root, Value>(
function setByPointer<Root extends {}, Value>(
root: Root,
getPointer: (ptr: Pointer<Root>) => Pointer<Value>,
newValue: Value,

View file

@ -233,7 +233,7 @@ class PrismInstance<V> implements Prism<V> {
}
// 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.

View file

@ -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"
}
}

View file

@ -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": {

View file

@ -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:*",

View file

@ -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:*",

View file

@ -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": {

View file

@ -129,7 +129,7 @@ function expectLastCalledWith(
}
}
function objMap<T, U>(
function objMap<T extends {}, U>(
template: T,
eachEntry: <P extends keyof T>(entry: [name: P, value: T[P]]) => U,
): {[P in keyof T]: U} {

View file

@ -72,7 +72,11 @@ export default function deepMergeWithCache<T extends SerializableMap>(
// @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

View file

@ -60,7 +60,7 @@ function typeOfValue(v: unknown): ValueType {
* })
* ```
*/
export default function minimalOverride<T>(base: T, override: T): T {
export default function minimalOverride<T extends {}>(base: T, override: T): T {
const typeofOverride = typeOfValue(override)
if (typeofOverride === ValueType.Opaque) {
return override

View file

@ -35,7 +35,7 @@ function cloneDeepSerializableAndPrune<T>(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 {

View file

@ -95,7 +95,7 @@ export const ProvideStyles: React.FC<{
)
}
export function withStyledShadow<Props>(
export function withStyledShadow<Props extends {}>(
Comp: React.ComponentType<Props>,
): React.ComponentType<Props> {
return (props) => (

View file

@ -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<T>(
export function setKeyframeAtPosition<T extends SerializableValue>(
p: WithoutSheetInstance<SheetObjectAddress> & {
trackId: SequenceTrackId
position: number

View file

@ -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<Props extends {}>(
finalComp.displayName = `deriver(${Component.displayName})`
return finalComp
return finalComp as $FixMe
}

View file

@ -7,12 +7,14 @@ import identity from 'lodash-es/identity'
import type {Store} from 'redux'
import {compose, createStore} from 'redux'
interface Conf<State> {
interface Conf<State extends {}> {
rootReducer: ReduxReducer<State>
devtoolsOptions?: $FixMe
}
export default function configureStore<State>(conf: Conf<State>): Store<State> {
export default function configureStore<State extends {}>(
conf: Conf<State>,
): Store<State> {
// const middlewares: $FixMe[] = []
const enhancers = []

View file

@ -22,7 +22,7 @@ let lastId = 1
export const getMounter = () => {
const id = lastId++
function mountOrRender<Props>(
function mountOrRender<Props extends {}>(
comp: React.ComponentType<Props>,
props: Props,
portalNode: HTMLElement,

View file

@ -8,7 +8,6 @@
"target": "ESNext",
"lib": ["es2017", "dom", "ESNext"],
"isolatedModules": true,
"importsNotUsedAsValues": "error",
"noFallthroughCasesInSwitch": true,
"jsx": "react",
"skipLibCheck": true,

View file

@ -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"