Skip to content

Commit 4ac54cf

Browse files
authored
Fix/types to prop types (#797)
* add babelrc file for src sub direrctory * prepare build configuration * migrate Swipeable to tsx cause it gave errors * generate d.ts for Swipeable component and ts-nocheck this file * update our build script * remove unused babel-preset-latest package
1 parent 9df248e commit 4ac54cf

File tree

6 files changed

+94
-14
lines changed

6 files changed

+94
-14
lines changed

babel.config.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
module.exports = {
22
env: {
33
test: {
4-
presets: ['module:metro-react-native-babel-preset'],
5-
retainLines: true,
6-
},
4+
presets: ['module:metro-react-native-babel-preset']
5+
}
76
},
8-
presets: ['module:metro-react-native-babel-preset'],
9-
retainLines: true,
10-
plugins: ['transform-inline-environment-variables'],
7+
presets: ['module:metro-react-native-babel-preset']
118
};
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import { Component } from 'react';
2+
import { Animated } from 'react-native';
3+
export declare type PropType = {
4+
children: any;
5+
friction: number;
6+
leftThreshold?: number;
7+
rightThreshold?: number;
8+
fullLeftThreshold?: number;
9+
fullSwipeLeft?: boolean;
10+
overshootLeft?: boolean;
11+
overshootRight?: boolean;
12+
overshootFriction?: number;
13+
onSwipeableLeftOpen?: Function;
14+
onSwipeableRightOpen?: Function;
15+
onSwipeableOpen?: Function;
16+
onSwipeableClose?: Function;
17+
onSwipeableLeftWillOpen?: Function;
18+
onSwipeableRightWillOpen?: Function;
19+
onSwipeableWillOpen?: Function;
20+
onSwipeableWillClose?: Function;
21+
onFullSwipeLeft?: Function;
22+
onWillFullSwipeLeft?: Function;
23+
onDragStart?: Function;
24+
renderLeftActions?: (progressAnimatedValue: any, dragAnimatedValue: any) => any;
25+
renderRightActions?: (progressAnimatedValue: any, dragAnimatedValue: any) => any;
26+
leftActionsContainerStyle: any;
27+
rightActionsContainerStyle: any;
28+
useNativeAnimations: boolean;
29+
animationOptions?: Object;
30+
containerStyle?: Object;
31+
childrenContainerStyle?: Object;
32+
};
33+
declare type StateType = {
34+
dragX: Animated.Value;
35+
rowTranslation: Animated.Value;
36+
leftWidth: number | typeof undefined;
37+
rightOffset: number | typeof undefined;
38+
rowWidth: number | typeof undefined;
39+
};
40+
export default class Swipeable extends Component<PropType, StateType> {
41+
static defaultProps: {
42+
friction: number;
43+
overshootFriction: number;
44+
useNativeAnimations: boolean;
45+
fullLeftThreshold: number;
46+
};
47+
constructor(props: PropType);
48+
UNSAFE_componentWillUpdate(props: PropType, state: StateType): void;
49+
_updateAnimatedEvent: (props: PropType, state: StateType) => void;
50+
_onTapHandlerStateChange: ({ nativeEvent }: {
51+
nativeEvent: any;
52+
}) => void;
53+
_onHandlerStateChange: ({ nativeEvent }: {
54+
nativeEvent: any;
55+
}) => void;
56+
_handleRelease: (nativeEvent: any) => void;
57+
_animateRow: (fromValue: any, toValue: any, velocityX: any) => void;
58+
_currentOffset: () => number;
59+
close: () => void;
60+
openLeft: () => void;
61+
openRight: () => void;
62+
_onRowLayout: ({ nativeEvent }: {
63+
nativeEvent: any;
64+
}) => void;
65+
_onLeftLayout: ({ nativeEvent }: {
66+
nativeEvent: any;
67+
}) => void;
68+
_onRightLayout: ({ nativeEvent }: {
69+
nativeEvent: any;
70+
}) => void;
71+
handleMeasure: (name: any, nativeEvent: any) => void;
72+
render(): JSX.Element;
73+
}
74+
export {};

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
"lint:test": "mocha --compilers js:babel-core/register eslint-rules/tests/lib/rules",
2727
"xcode": "open ./ios/uilib.xcodeproj",
2828
"build:dev": "tsc --p tsconfig.dev.json",
29-
"build": "tsc --p tsconfig.build.json",
29+
"build:exports": "./node_modules/.bin/babel src --out-dir src --config-file ./src/.babelrc.json --extensions '.ts,.tsx' --ignore 'src/index.ts'",
30+
"build": "tsc --p tsconfig.build.json && npm run build:exports",
3031
"log": "react-native log-ios | grep 'ethan -'",
3132
"docs:install": "(cd ./uilib-docs && rm -rf node_modules && rm -rf package-lock.json && npm install)",
3233
"docs:deploy": "(cd ./uilib-docs && gatsby build --prefix-paths && gh-pages -d public --branch gh-pages)",
@@ -56,8 +57,10 @@
5657
"url-parse": "^1.2.0"
5758
},
5859
"devDependencies": {
60+
"@babel/cli": "^7.10.1",
5961
"@babel/core": "^7.4.0",
6062
"@babel/preset-env": "^7.3.1",
63+
"@babel/preset-react": "^7.10.1",
6164
"@babel/runtime": "^7.4.2",
6265
"@react-native-community/async-storage": "^1.6.2",
6366
"@react-native-community/blur": "^3.4.1",
@@ -72,6 +75,7 @@
7275
"@typescript-eslint/parser": "^2.13.0",
7376
"@welldone-software/why-did-you-render": "^3.2.1",
7477
"babel-jest": "^25.2.4",
78+
"babel-plugin-typescript-to-proptypes": "^1.3.2",
7579
"babel-preset-react-native": "*",
7680
"eslint": "^5.16.0",
7781
"eslint-config-wix": "^1.1.28",

src/.babelrc.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"presets": ["@babel/preset-typescript", "@babel/preset-react"],
3+
"plugins": ["babel-plugin-typescript-to-proptypes"]
4+
}

src/components/drawer/Swipeable.js renamed to src/components/drawer/Swipeable.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @ts-nocheck
12
// @flow
23
// Similarly to the DrawerLayout component this deserves to be put in a
34
// separate repo. Although, keeping it here for the time being will allow us
@@ -67,12 +68,12 @@ export default class Swipeable extends Component<PropType, StateType> {
6768
fullLeftThreshold: 0.45
6869
};
6970

70-
_onGestureEvent: ?Animated.Event;
71-
_transX: ?Animated.Interpolation;
72-
_showLeftAction: ?Animated.Interpolation | ?Animated.Value;
73-
_leftActionTranslate: ?Animated.Interpolation;
74-
_showRightAction: ?Animated.Interpolation | ?Animated.Value;
75-
_rightActionTranslate: ?Animated.Interpolation;
71+
// _onGestureEvent: ?Animated.Event;
72+
// _transX: ?Animated.Interpolation;
73+
// _showLeftAction: ?Animated.Interpolation | ?Animated.Value;
74+
// _leftActionTranslate: ?Animated.Interpolation;
75+
// _showRightAction: ?Animated.Interpolation | ?Animated.Value;
76+
// _rightActionTranslate: ?Animated.Interpolation;
7677

7778
constructor(props: PropType) {
7879
super(props);

tsconfig.build.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"extends": "./tsconfig",
33
"compilerOptions": {
4-
"emitDeclarationOnly": false
4+
"emitDeclarationOnly": true
55
},
66
"include": ["src/**/*", "typings/**/*"],
77
"exclude": [ "node_modules", "src/index.ts"]

0 commit comments

Comments
 (0)