From a85c080ce2639b33a65f2c48c3f4ec7fda46eb7f Mon Sep 17 00:00:00 2001 From: Konstantin Vasilev Date: Mon, 5 Jun 2017 11:40:42 +0300 Subject: [PATCH 1/4] Upgrade react-swipeable to v4.0 --- types/react-swipeable/index.d.ts | 44 ++++++--------- .../react-swipeable/react-swipeable-tests.tsx | 56 +++++++++++++------ types/react-swipeable/tslint.json | 3 + 3 files changed, 58 insertions(+), 45 deletions(-) create mode 100644 types/react-swipeable/tslint.json diff --git a/types/react-swipeable/index.d.ts b/types/react-swipeable/index.d.ts index fadf0f057f..da72f528e3 100644 --- a/types/react-swipeable/index.d.ts +++ b/types/react-swipeable/index.d.ts @@ -1,29 +1,19 @@ -// Type definitions for react-swipeable 3.3.1 +// Type definitions for react-swipeable 4.0 // Project: https://www.npmjs.com/package/react-swipeable // Definitions by: Giedrius Grabauskas // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.1 +// TypeScript Version: 2.2 -/// +declare module 'react-swipeable' { + import * as React from 'react'; -declare namespace ReactSwipeableModule { - interface onSwipingCallback { - (event: React.TouchEvent, deltaX: number, deltaY: number, absX: number, absY: number, velocity: number): 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 OnSwipedCallback { - (event: React.TouchEvent, deltaX: number, deltaY: number, isFlick: boolean, velocity: number): void; - } - - interface OnSwipedDirectionCallback { - (event: React.TouchEvent, delta: number, isFlick: boolean): void; - } - - interface OnSwipingDirectionCallback { - (event: React.TouchEvent, delta: number): void; - } - - interface Props { + interface Props extends React.ClassAttributes, React.HTMLAttributes { onSwiped?: OnSwipedCallback; onSwiping?: onSwipingCallback; onSwipingUp?: OnSwipingDirectionCallback; @@ -34,18 +24,18 @@ declare namespace ReactSwipeableModule { onSwipedRight?: OnSwipedDirectionCallback; onSwipedDown?: OnSwipedDirectionCallback; onSwipedLeft?: OnSwipedDirectionCallback; + onTap?: OnTapCallback; flickThreshold?: number; delta?: number; preventDefaultTouchmoveEvent?: boolean; + stopPropagation?: boolean; nodeName?: string; + trackMouse?: boolean; + children?: React.ReactNode; } - interface ReactSwipeable extends React.ComponentClass { } + class ReactSwipeable extends React.Component {} + namespace ReactSwipeable {} -} - - -declare module "react-swipeable" { - let module: ReactSwipeableModule.ReactSwipeable; - export = module; + export = ReactSwipeable; } diff --git a/types/react-swipeable/react-swipeable-tests.tsx b/types/react-swipeable/react-swipeable-tests.tsx index 7e8682ade7..05e057c11f 100644 --- a/types/react-swipeable/react-swipeable-tests.tsx +++ b/types/react-swipeable/react-swipeable-tests.tsx @@ -1,26 +1,46 @@ -import Swipeable = require('react-swipeable'); -import React = require('react'); +import * as React from 'react'; +import * as Swipeable from 'react-swipeable'; -var SampleComponent = React.createClass({ - render: function () { +class SampleComponent extends React.PureComponent { + private handleSwiped = () => {}; + private handleSwiping = () => {}; + private handleSwipingUp = () => {}; + private handleSwipingRight = () => {}; + private handleSwipingDown = () => {}; + private handleSwipingLeft = () => {}; + private handleSwipedUp = () => {}; + private handleSwipedRight = () => {}; + private handleSwipedDown = () => {}; + private handleSwipedLeft = () => {}; + private handleTap = () => {}; + private handleClick = () => {}; + + render() { return ( + onSwiped={this.handleSwiped} + onSwiping={this.handleSwiping} + onSwipingUp={this.handleSwipingUp} + onSwipingRight={this.handleSwipingRight} + onSwipingDown={this.handleSwipingDown} + onSwipingLeft={this.handleSwipingLeft} + onSwipedUp={this.handleSwipedUp} + onSwipedRight={this.handleSwipedRight} + onSwipedDown={this.handleSwipedDown} + onSwipedLeft={this.handleSwipedLeft} + onTap={this.handleTap} + flickThreshold={10} + delta={10} + preventDefaultTouchmoveEvent + stopPropagation + nodeName="swipe" + trackMouse + onClick={this.handleClick} + >
This element can be swiped
- ) + ); } -}) +} diff --git a/types/react-swipeable/tslint.json b/types/react-swipeable/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/react-swipeable/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} From 52fbfebcb6051948ac425ac5e2c797c3ed3bc04b Mon Sep 17 00:00:00 2001 From: Konstantin Vasilev Date: Mon, 5 Jun 2017 12:01:17 +0300 Subject: [PATCH 2/4] fix single module declaration --- types/react-swipeable/index.d.ts | 62 ++++++++++++++++---------------- 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/types/react-swipeable/index.d.ts b/types/react-swipeable/index.d.ts index da72f528e3..489964ee0c 100644 --- a/types/react-swipeable/index.d.ts +++ b/types/react-swipeable/index.d.ts @@ -4,38 +4,36 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 -declare module 'react-swipeable' { - import * as React from 'react'; +import * as React from 'react'; - 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 Props 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; - children?: React.ReactNode; - } - - class ReactSwipeable extends React.Component {} - namespace ReactSwipeable {} - - export = ReactSwipeable; +interface Props 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; + children?: React.ReactNode; } + +declare class ReactSwipeable extends React.Component {} +declare namespace ReactSwipeable {} + +export = ReactSwipeable; From 76879cce23fcae9847a57bb61cc27432e2a20532 Mon Sep 17 00:00:00 2001 From: Konstantin Vasilev Date: Tue, 6 Jun 2017 10:04:43 +0300 Subject: [PATCH 3/4] export types references --- types/react-swipeable/index.d.ts | 58 ++++++++++--------- .../react-swipeable/react-swipeable-tests.tsx | 24 ++++---- 2 files changed, 42 insertions(+), 40 deletions(-) diff --git a/types/react-swipeable/index.d.ts b/types/react-swipeable/index.d.ts index 489964ee0c..b646a46268 100644 --- a/types/react-swipeable/index.d.ts +++ b/types/react-swipeable/index.d.ts @@ -1,39 +1,41 @@ // Type definitions for react-swipeable 4.0 // Project: https://www.npmjs.com/package/react-swipeable -// Definitions by: Giedrius Grabauskas +// Definitions by: Giedrius Grabauskas , +// Konstantin Vasilev // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 import * as React from 'react'; -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; +declare class ReactSwipeable extends React.Component {} -interface Props 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; - children?: React.ReactNode; +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; + + 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; + children?: React.ReactNode; + } } -declare class ReactSwipeable extends React.Component {} -declare namespace ReactSwipeable {} - export = ReactSwipeable; diff --git a/types/react-swipeable/react-swipeable-tests.tsx b/types/react-swipeable/react-swipeable-tests.tsx index 05e057c11f..c75869bdb0 100644 --- a/types/react-swipeable/react-swipeable-tests.tsx +++ b/types/react-swipeable/react-swipeable-tests.tsx @@ -1,18 +1,18 @@ import * as React from 'react'; import * as Swipeable from 'react-swipeable'; -class SampleComponent extends React.PureComponent { - private handleSwiped = () => {}; - private handleSwiping = () => {}; - private handleSwipingUp = () => {}; - private handleSwipingRight = () => {}; - private handleSwipingDown = () => {}; - private handleSwipingLeft = () => {}; - private handleSwipedUp = () => {}; - private handleSwipedRight = () => {}; - private handleSwipedDown = () => {}; - private handleSwipedLeft = () => {}; - private handleTap = () => {}; +class SampleComponent extends React.PureComponent { + private handleSwiped: Swipeable.OnSwipedCallback = () => {}; + private handleSwiping: Swipeable.OnSwipingCallback = () => {}; + private handleSwipingUp: Swipeable.OnSwipingDirectionCallback = () => {}; + private handleSwipingRight: Swipeable.OnSwipingDirectionCallback = () => {}; + private handleSwipingDown: Swipeable.OnSwipingDirectionCallback = () => {}; + private handleSwipingLeft: Swipeable.OnSwipingDirectionCallback = () => {}; + private handleSwipedUp: Swipeable.OnSwipedDirectionCallback = () => {}; + private handleSwipedRight: Swipeable.OnSwipedDirectionCallback = () => {}; + private handleSwipedDown: Swipeable.OnSwipedDirectionCallback = () => {}; + private handleSwipedLeft: Swipeable.OnSwipedDirectionCallback = () => {}; + private handleTap: Swipeable.OnTapCallback = () => {}; private handleClick = () => {}; render() { From 67596b61d7f848328d80a02bdf1d385d917cdaf6 Mon Sep 17 00:00:00 2001 From: Konstantin Vasilev Date: Tue, 6 Jun 2017 16:24:59 +0300 Subject: [PATCH 4/4] remove unnecessary comma in authors section --- types/react-swipeable/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-swipeable/index.d.ts b/types/react-swipeable/index.d.ts index b646a46268..7692abd859 100644 --- a/types/react-swipeable/index.d.ts +++ b/types/react-swipeable/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for react-swipeable 4.0 // Project: https://www.npmjs.com/package/react-swipeable -// Definitions by: Giedrius Grabauskas , +// Definitions by: Giedrius Grabauskas // Konstantin Vasilev // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2