diff --git a/types/react-swipeable/index.d.ts b/types/react-swipeable/index.d.ts index b0036ae119..1608258c64 100644 --- a/types/react-swipeable/index.d.ts +++ b/types/react-swipeable/index.d.ts @@ -1,39 +1,42 @@ -// Type definitions for react-swipeable 4.0 +// Type definitions for react-swipeable 4.2 // Project: https://www.npmjs.com/package/react-swipeable // Definitions by: Giedrius Grabauskas // Konstantin Vasilev +// Hiroki Horiuchi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 import * as React from 'react'; -declare class ReactSwipeable extends React.Component {} +declare class ReactSwipeable extends React.Component> {} declare namespace ReactSwipeable { - type OnSwipingCallback = (event: React.TouchEvent, deltaX: number, deltaY: number, absX: number, absY: number, velocity: number) => void; - type OnSwipedCallback = (event: React.TouchEvent, deltaX: number, deltaY: number, isFlick: boolean, velocity: number) => void; - type OnSwipedDirectionCallback = (event: React.TouchEvent, delta: number, isFlick: boolean) => void; - type OnSwipingDirectionCallback = (event: React.TouchEvent, delta: number) => void; - type OnTapCallback = (event: React.TouchEvent) => void; + type OnSwipingCallback = (event: React.TouchEvent, deltaX: number, deltaY: number, absX: number, absY: number, velocity: number) => void; + type OnSwipedCallback = (event: React.TouchEvent, deltaX: number, deltaY: number, isFlick: boolean, velocity: number) => void; + type OnSwipedDirectionCallback = (event: React.TouchEvent, delta: number, isFlick: boolean) => void; + type OnSwipingDirectionCallback = (event: React.TouchEvent, delta: number) => void; + type OnTapCallback = (event: React.TouchEvent) => void; - interface SwipeableProps extends React.ClassAttributes, React.HTMLAttributes { - onSwiped?: OnSwipedCallback; - onSwiping?: OnSwipingCallback; - onSwipingUp?: OnSwipingDirectionCallback; - onSwipingRight?: OnSwipingDirectionCallback; - onSwipingDown?: OnSwipingDirectionCallback; - onSwipingLeft?: OnSwipingDirectionCallback; - onSwipedUp?: OnSwipedDirectionCallback; - onSwipedRight?: OnSwipedDirectionCallback; - onSwipedDown?: OnSwipedDirectionCallback; - onSwipedLeft?: OnSwipedDirectionCallback; - onTap?: OnTapCallback; + interface SwipeableProps extends React.ClassAttributes>, React.HTMLAttributes { + onSwiped?: OnSwipedCallback; + onSwiping?: OnSwipingCallback; + onSwipingUp?: OnSwipingDirectionCallback; + onSwipingRight?: OnSwipingDirectionCallback; + onSwipingDown?: OnSwipingDirectionCallback; + onSwipingLeft?: OnSwipingDirectionCallback; + onSwipedUp?: OnSwipedDirectionCallback; + onSwipedRight?: OnSwipedDirectionCallback; + onSwipedDown?: OnSwipedDirectionCallback; + onSwipedLeft?: OnSwipedDirectionCallback; + onTap?: OnTapCallback; flickThreshold?: number; delta?: number; preventDefaultTouchmoveEvent?: boolean; stopPropagation?: boolean; nodeName?: string; trackMouse?: boolean; + disabled?: boolean; + innerRef?: React.Ref; children?: React.ReactNode; } } diff --git a/types/react-swipeable/react-swipeable-tests.tsx b/types/react-swipeable/react-swipeable-tests.tsx index 61093a203e..ed5df52e54 100644 --- a/types/react-swipeable/react-swipeable-tests.tsx +++ b/types/react-swipeable/react-swipeable-tests.tsx @@ -35,6 +35,8 @@ class SampleComponent extends React.PureComponent { stopPropagation nodeName="swipe" trackMouse + disabled + innerRef="swipe-ref" onClick={this.handleClick} >
@@ -44,3 +46,16 @@ class SampleComponent extends React.PureComponent { ); } } + +class DivSwipeable extends Swipeable {} +const TestComponent: React.StatelessComponent = (_) => { + const handleSwiped = (event: React.TouchEvent) => {}; + return ( + +
this is sample code.
+
+ ); +}; diff --git a/types/react-swipeable/tsconfig.json b/types/react-swipeable/tsconfig.json index 0d676ade9b..a720949edf 100644 --- a/types/react-swipeable/tsconfig.json +++ b/types/react-swipeable/tsconfig.json @@ -6,8 +6,8 @@ "dom" ], "noImplicitAny": true, - "noImplicitThis": false, - "strictNullChecks": false, + "noImplicitThis": true, + "strictNullChecks": true, "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ @@ -22,4 +22,4 @@ "index.d.ts", "react-swipeable-tests.tsx" ] -} \ No newline at end of file +}