Skip to content

Commit

Permalink
Replace Omit with Pick + Exclude (#899)
Browse files Browse the repository at this point in the history
Recently the type declarations include the use of the Omit library type. This type was added in TypeScript 3.5 (typescriptlang.org/docs/handbook/release-notes/typescript-3-5.html#the-omit-helper-type), and therefore the change prevents using this library with TypeScript projects that have not upgraded. (In my case, we use TypeScript 3.4.)

I replaced the use of Omit with the same implementation based on Pick and Exclude:
type Omit<T, K extends keyof any> = Pick<T, Exclude<keyof T, K>>;

I'm not sure what the minimum TypeScript this project supports, but this will at least prevent issues with some earlier 3.x versions.
  • Loading branch information
newyankeecodeshop authored and osdnk committed Jan 2, 2020
1 parent e4de5d9 commit 4673c67
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion react-native-gesture-handler.d.ts
Expand Up @@ -466,7 +466,9 @@ declare module 'react-native-gesture-handler' {
declare module 'react-native-gesture-handler/Swipeable' {
import { Animated, StyleProp, ViewStyle } from 'react-native';
import { PanGestureHandlerProperties } from 'react-native-gesture-handler'
interface SwipeableProperties extends Omit<PanGestureHandlerProperties, 'onGestureEvent' | 'onHandlerStateChange'> {
type SwipeableExcludes = Exclude<keyof PanGestureHandlerProperties, 'onGestureEvent' | 'onHandlerStateChange'>

interface SwipeableProperties extends Pick<PanGestureHandlerProperties, SwipeableExcludes> {
friction?: number;
leftThreshold?: number;
rightThreshold?: number;
Expand Down

0 comments on commit 4673c67

Please sign in to comment.