-
Notifications
You must be signed in to change notification settings - Fork 311
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
Conversation
|
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:
|
@@ -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']) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ref
- TypeScript: TS Playground
NonNullable<T>['event']
=> Type 'string' cannot be used to index type 'NonNullable'.(2536)
@@ -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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
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...
)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 preparedStateTypes
exclude optional property, then I replaced the type wrappedNonNullable
withStateTypes[Key]
.Related
NonNullable
of a generic type in typescript 4.8 · Issue #49681 · microsoft/TypeScript