Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: support TypeScript 4.8 #534

Closed
wants to merge 1 commit into from

Conversation

ergofriend
Copy link

@ergofriend ergofriend commented Aug 30, 2022

Background

I wanna update a project to TypeScript 4.8 (it depends on @use-gesture/react), but I got error (error TS2339: Property 'active' does not exist...)

image

internal error (packages/core/src/engines/Engine.ts)

NonNullable<T>['event'].target => Property 'target' does not exist on type 'NonNullable<State[Key]>["event"]'.ts(2339)

Changed

TypeScript 4.8 can't access indexed type of i.e. NonNullable<{drag?: {...} }>[index], So I prepared StateTypes exclude optional property, then I replaced the type wrapped NonNullable with StateTypes[Key].

Related

@changeset-bot
Copy link

changeset-bot bot commented Aug 30, 2022

⚠️ No Changeset found

Latest commit: 5faf46d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 5faf46d:

Sandbox Source
gesture-drag Configuration
gesture-drag-target Configuration
gesture-nested Configuration
gesture-drag-vanilla Configuration
gesture-move Configuration
gesture-pinch Configuration
gesture-multiple-pinch Configuration
gesture-three Configuration
gesture-card-zoom Configuration
gesture-viewpager Configuration

@@ -179,7 +179,7 @@ export abstract class Engine<Key extends GestureKey> {
* Function ran at the start of the gesture.
* @param event
*/
start(event: NonNullable<State[Key]>['event']) {
start(event: StateTypes[Key]['event']) {
Copy link
Author

Choose a reason for hiding this comment

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

ref

@@ -152,7 +152,7 @@ export type DragConfig = Omit<CoordinatesConfig<'drag'>, 'axisThreshold' | 'boun
* Limits the gesture `offset` to the specified bounds. Can be a ref or a dom
* node.
*/
bounds?: DragBounds | ((state: State['drag']) => DragBounds)
bounds?: DragBounds | ((state: StateTypes['drag']) => DragBounds)
Copy link
Author

Choose a reason for hiding this comment

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

cared for
image

@dbismut
Copy link
Collaborator

dbismut commented Aug 30, 2022

Hey, I've already taken care of this in #512, specifically this commit 0f97c17.

I just had to define the pre-4.8 NonNullable mapped type definition and that's it as explained here #501 (comment)

I'm going to close this. Since it's a pressing issue though, I'll make a separate PR for it today so that you don't have to wait for #512.

@dbismut dbismut closed this Aug 30, 2022
@ergofriend ergofriend deleted the support-typescript-4.8 branch August 30, 2022 23:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants