Skip to content

Commit

Permalink
chore: update codebase to TS 5 (#2210)
Browse files Browse the repository at this point in the history
* chore: update codebase to TS 5

* chore: update workflow to test against typescript 5 and above
joshuaellis authored Oct 4, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 075468c commit 02ec877
Showing 48 changed files with 51 additions and 85 deletions.
11 changes: 2 additions & 9 deletions .github/publish-ci/cra4/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
@@ -20,7 +15,5 @@
"noEmit": true,
"jsx": "react-jsx"
},
"include": [
"src"
]
"include": ["src"]
}
11 changes: 2 additions & 9 deletions .github/publish-ci/cra5/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
@@ -20,7 +15,5 @@
"noEmit": true,
"jsx": "react-jsx"
},
"include": [
"src"
]
"include": ["src"]
}
17 changes: 3 additions & 14 deletions .github/publish-ci/next/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
@@ -19,12 +14,6 @@
"jsx": "preserve",
"incremental": true
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx"
],
"exclude": [
"node_modules"
]
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}
1 change: 0 additions & 1 deletion .github/publish-ci/vite/tsconfig.json
Original file line number Diff line number Diff line change
@@ -8,7 +8,6 @@
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -123,7 +123,7 @@ jobs:
strategy:
matrix:
node: ['18.x']
ts: ['4.5', '4.6', '4.7', '4.8', '4.9']
ts: ['5.0', '5.1', '5.2']

steps:
- name: Checkout repo
1 change: 0 additions & 1 deletion demo/src/sandboxes/animating-auto/tsconfig.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
"jsx": "react",
"moduleResolution": "node",
"rootDir": "src",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
1 change: 0 additions & 1 deletion demo/src/sandboxes/card/tsconfig.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
"jsx": "react",
"moduleResolution": "node",
"rootDir": "src",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
1 change: 0 additions & 1 deletion demo/src/sandboxes/cards-stack/tsconfig.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
"jsx": "react",
"moduleResolution": "node",
"rootDir": "src",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
1 change: 0 additions & 1 deletion demo/src/sandboxes/chain/tsconfig.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
"jsx": "react",
"moduleResolution": "node",
"rootDir": "src",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
1 change: 0 additions & 1 deletion demo/src/sandboxes/css-gradients/tsconfig.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
"jsx": "react",
"moduleResolution": "node",
"rootDir": "src",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
1 change: 0 additions & 1 deletion demo/src/sandboxes/css-keyframes/tsconfig.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
"jsx": "react",
"moduleResolution": "node",
"rootDir": "src",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
1 change: 0 additions & 1 deletion demo/src/sandboxes/css-variables/tsconfig.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
"jsx": "react",
"moduleResolution": "node",
"rootDir": "src",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
1 change: 0 additions & 1 deletion demo/src/sandboxes/draggable-list/tsconfig.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
"jsx": "react",
"moduleResolution": "node",
"rootDir": "src",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
1 change: 0 additions & 1 deletion demo/src/sandboxes/exit-before-enter/tsconfig.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
"jsx": "react",
"moduleResolution": "node",
"rootDir": "src",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
1 change: 0 additions & 1 deletion demo/src/sandboxes/flip-card/tsconfig.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
"jsx": "react",
"moduleResolution": "node",
"rootDir": "src",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
1 change: 0 additions & 1 deletion demo/src/sandboxes/floating-button/tsconfig.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
"jsx": "react",
"moduleResolution": "node",
"rootDir": "src",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
1 change: 0 additions & 1 deletion demo/src/sandboxes/goo-blobs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
"jsx": "react",
"moduleResolution": "node",
"rootDir": "src",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
1 change: 0 additions & 1 deletion demo/src/sandboxes/image-fade/tsconfig.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
"jsx": "react",
"moduleResolution": "node",
"rootDir": "src",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
1 change: 0 additions & 1 deletion demo/src/sandboxes/list-reordering/tsconfig.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
"jsx": "react",
"moduleResolution": "node",
"rootDir": "src",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
1 change: 0 additions & 1 deletion demo/src/sandboxes/macos-dock/tsconfig.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
"jsx": "react",
"moduleResolution": "node",
"rootDir": "src",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
1 change: 0 additions & 1 deletion demo/src/sandboxes/masonry/tsconfig.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
"jsx": "react",
"moduleResolution": "node",
"rootDir": "src",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
1 change: 0 additions & 1 deletion demo/src/sandboxes/multistage-transition/tsconfig.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
"jsx": "react",
"moduleResolution": "node",
"rootDir": "src",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
1 change: 0 additions & 1 deletion demo/src/sandboxes/notification-hub/tsconfig.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
"jsx": "react",
"moduleResolution": "node",
"rootDir": "src",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
1 change: 0 additions & 1 deletion demo/src/sandboxes/parallax-sticky/tsconfig.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
"jsx": "react",
"moduleResolution": "node",
"rootDir": "src",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
1 change: 0 additions & 1 deletion demo/src/sandboxes/parallax-vert/tsconfig.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
"jsx": "react",
"moduleResolution": "node",
"rootDir": "src",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
1 change: 0 additions & 1 deletion demo/src/sandboxes/parallax/tsconfig.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
"jsx": "react",
"moduleResolution": "node",
"rootDir": "src",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
1 change: 0 additions & 1 deletion demo/src/sandboxes/popup-modal/tsconfig.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
"jsx": "react",
"moduleResolution": "node",
"rootDir": "src",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
1 change: 0 additions & 1 deletion demo/src/sandboxes/rocket-decay/tsconfig.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
"jsx": "react",
"moduleResolution": "node",
"rootDir": "src",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
1 change: 0 additions & 1 deletion demo/src/sandboxes/scrolling-wave/tsconfig.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
"jsx": "react",
"moduleResolution": "node",
"rootDir": "src",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
1 change: 0 additions & 1 deletion demo/src/sandboxes/simple-transition/tsconfig.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
"jsx": "react",
"moduleResolution": "node",
"rootDir": "src",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
1 change: 0 additions & 1 deletion demo/src/sandboxes/slide/tsconfig.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
"jsx": "react",
"moduleResolution": "node",
"rootDir": "src",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
1 change: 0 additions & 1 deletion demo/src/sandboxes/smile-grid/tsconfig.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
"jsx": "react",
"moduleResolution": "node",
"rootDir": "src",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
1 change: 0 additions & 1 deletion demo/src/sandboxes/springy-boxes/tsconfig.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
"jsx": "react",
"moduleResolution": "node",
"rootDir": "src",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
1 change: 0 additions & 1 deletion demo/src/sandboxes/svg-filter/tsconfig.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
"jsx": "react",
"moduleResolution": "node",
"rootDir": "src",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
1 change: 0 additions & 1 deletion demo/src/sandboxes/trail/tsconfig.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
"jsx": "react",
"moduleResolution": "node",
"rootDir": "src",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
1 change: 0 additions & 1 deletion demo/src/sandboxes/tree/tsconfig.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
"jsx": "react",
"moduleResolution": "node",
"rootDir": "src",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
1 change: 0 additions & 1 deletion demo/src/sandboxes/viewpager/tsconfig.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
"jsx": "react",
"moduleResolution": "node",
"rootDir": "src",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
1 change: 0 additions & 1 deletion demo/src/sandboxes/webgl-switch/tsconfig.json
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
"jsx": "react",
"moduleResolution": "node",
"rootDir": "src",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
1 change: 0 additions & 1 deletion demo/tsconfig.json
Original file line number Diff line number Diff line change
@@ -8,7 +8,6 @@
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -106,7 +106,7 @@
"three": "^0.150.1",
"tsup": "^6.7.0",
"turbo": "^1.8.3",
"typescript": "4.9.5",
"typescript": "5.2.2",
"vite": "^4.1.4",
"zdog": "^1.1.3"
},
1 change: 1 addition & 0 deletions packages/core/src/hooks/useInView.ts
Original file line number Diff line number Diff line change
@@ -66,6 +66,7 @@ export function useInView<TElement extends HTMLElement>(

const onEnter = () => {
if (to) {
// @ts-expect-error – TODO: fix this type error
api.start(to)
}

1 change: 1 addition & 0 deletions packages/core/src/hooks/useTrail.test.tsx
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@ describe('useTrail', () => {
// Call the "useSprings" hook and update local variables.
const update = createUpdater(({ args }) => {
const result = useTrail(...args)
// @ts-expect-error - TODO: fix this type error.
springs = is.arr(result[0]) ? result[0] : result
return null
})
19 changes: 13 additions & 6 deletions packages/core/test/setup.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-var */
import createMockRaf, { MockRaf } from 'mock-raf'
import { flushMicroTasks } from 'flush-microtasks'
import { act } from '@testing-library/react'
@@ -107,7 +108,12 @@ global.countBounces = spring => {
let prev = from
let count = 0
global.getFrames(spring, true).forEach(value => {
if (value !== to && value > to !== prev > to) {
if (
value !== to &&
is.num(to) &&
is.num(prev) &&
value > to !== prev > to
) {
count += 1
}
prev = value
@@ -174,11 +180,12 @@ global.advanceUntilValue = (spring, value) => {
const frames = global.getFrames(spring, true)
const value = frames.length - offset > 0 ? frames[frames.length - 1] : from

const stop = is.num(goal)
? goal > from
? goal <= value
: goal >= value
: isEqual(value, goal)
const stop =
is.num(goal) && is.num(value) && is.num(from)
? goal > from
? goal <= value
: goal >= value
: isEqual(value, goal)

return stop
})
1 change: 0 additions & 1 deletion packages/parallax/test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -8,7 +8,6 @@
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
4 changes: 2 additions & 2 deletions packages/shared/src/createInterpolator.test.ts
Original file line number Diff line number Diff line change
@@ -23,8 +23,8 @@ describe('Interpolation', () => {
})

it('should work with interpolation function as argument', () => {
const interpolation = createInterpolator(
(value: number) => `scale(${value})`
const interpolation = createInterpolator<number, string>(
value => `scale(${value})`
)

expect(interpolation(0)).toBe('scale(0)')
4 changes: 2 additions & 2 deletions packages/shared/src/dom-events/scroll/ScrollHandler.ts
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ const SCROLL_KEYS = {
length: 'Height',
position: 'Top',
},
}
} as const

/**
* Whilst user's may not need the scrollLength, it's easier to return
@@ -60,7 +60,7 @@ export class ScrollHandler {

axis.current = this.container[`scroll${position}`]
axis.scrollLength =
this.container['scroll' + length] - this.container['client' + length]
this.container[`scroll${length}`] - this.container[`client${length}`]

axis.progress = progress(0, axis.scrollLength, axis.current)
}
2 changes: 0 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -26,8 +26,6 @@
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"suppressImplicitAnyIndexErrors": true,
"strictNullChecks": true
}
}
26 changes: 23 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -17728,7 +17728,7 @@ __metadata:
three: ^0.150.1
tsup: ^6.7.0
turbo: ^1.8.3
typescript: 4.9.5
typescript: 5.2.2
vite: ^4.1.4
zdog: ^1.1.3
languageName: unknown
@@ -20396,7 +20396,17 @@ __metadata:
languageName: node
linkType: hard

"typescript@npm:4.9.5, typescript@npm:^4.6.4":
"typescript@npm:5.2.2":
version: 5.2.2
resolution: "typescript@npm:5.2.2"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 7912821dac4d962d315c36800fe387cdc0a6298dba7ec171b350b4a6e988b51d7b8f051317786db1094bd7431d526b648aba7da8236607febb26cf5b871d2d3c
languageName: node
linkType: hard

"typescript@npm:^4.6.4":
version: 4.9.5
resolution: "typescript@npm:4.9.5"
bin:
@@ -20416,7 +20426,17 @@ __metadata:
languageName: node
linkType: hard

"typescript@patch:typescript@4.9.5#~builtin<compat/typescript>, typescript@patch:typescript@^4.6.4#~builtin<compat/typescript>":
"typescript@patch:typescript@5.2.2#~builtin<compat/typescript>":
version: 5.2.2
resolution: "typescript@patch:typescript@npm%3A5.2.2#~builtin<compat/typescript>::version=5.2.2&hash=1f5320"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 07106822b4305de3f22835cbba949a2b35451cad50888759b6818421290ff95d522b38ef7919e70fb381c5fe9c1c643d7dea22c8b31652a717ddbd57b7f4d554
languageName: node
linkType: hard

"typescript@patch:typescript@^4.6.4#~builtin<compat/typescript>":
version: 4.9.5
resolution: "typescript@patch:typescript@npm%3A4.9.5#~builtin<compat/typescript>::version=4.9.5&hash=23ec76"
bin:

1 comment on commit 02ec877

@vercel
Copy link

@vercel vercel bot commented on 02ec877 Oct 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.