diff --git a/types/react-native-fs/react-native-fs-tests.ts b/types/react-native-fs/react-native-fs-tests.ts index a006086a9a..85a623b82e 100644 --- a/types/react-native-fs/react-native-fs-tests.ts +++ b/types/react-native-fs/react-native-fs-tests.ts @@ -1,6 +1,5 @@ import * as RNFS from 'react-native-fs'; - // get a list of files and directories in the main bundle RNFS.readDir(RNFS.MainBundlePath) // On Android, use "RNFS.DocumentDirectoryPath" (MainBundlePath is not defined) .then((result) => { @@ -26,7 +25,7 @@ RNFS.readDir(RNFS.MainBundlePath) // On Android, use "RNFS.DocumentDirectoryPath }); // create a path you want to write to -var path = RNFS.DocumentDirectoryPath + '/test.txt'; +const path = RNFS.DocumentDirectoryPath + '/test.txt'; // write the file RNFS.writeFile(path, 'Lorem ipsum dolor sit amet', 'utf8') @@ -46,9 +45,9 @@ RNFS.unlink('path') console.log(err.message); }); -var uploadUrl = 'http://requestb.in/XXXXXXX'; // For testing purposes, go to http://requestb.in/ and create your own link +const uploadUrl = 'http://requestb.in/XXXXXXX'; // For testing purposes, go to http://requestb.in/ and create your own link // create an array of objects of the files you want to upload -var files = [ +const files = [ { name: 'test1', filename: 'test1.w4a', @@ -62,13 +61,13 @@ var files = [ } ]; -var uploadBegin: RNFS.UploadCallbackBegin = (response) => { - var jobId = response.jobId; +const uploadBegin: RNFS.UploadCallbackBegin = (response) => { + const jobId = response.jobId; console.log('UPLOAD HAS BEGUN! JobId: ' + jobId); }; -var uploadProgress: RNFS.UploadCallbackProgress = (response) => { - var percentage = Math.floor((response.totalBytesSent / response.totalBytesExpectedToSend) * 100); +const uploadProgress: RNFS.UploadCallbackProgress = (response) => { + const percentage = Math.floor((response.totalBytesSent / response.totalBytesExpectedToSend) * 100); console.log('UPLOAD IS ' + percentage + '% DONE!'); }; @@ -99,13 +98,13 @@ RNFS.uploadFiles({ console.log(err); }); -var downloadProgress: RNFS.DownloadCallbackProgress = (result) => { +const downloadProgress: RNFS.DownloadCallbackProgress = (result) => { result.bytesWritten === 0; result.contentLength > 10; result.jobId; }; -var downloadBegin: RNFS.DownloadCallbackBegin = (result) => { +const downloadBegin: RNFS.DownloadCallbackBegin = (result) => { result.headers === {}; }; diff --git a/types/react-native-scrollable-tab-view/index.d.ts b/types/react-native-scrollable-tab-view/index.d.ts index 873d69855b..9ef7e5a247 100644 --- a/types/react-native-scrollable-tab-view/index.d.ts +++ b/types/react-native-scrollable-tab-view/index.d.ts @@ -23,8 +23,7 @@ export interface onChangeTabProperties { } export interface renderTabBarProperties { - - goToPage: (pageNumber: number) => void; + goToPage(pageNumber: number): void; tabs: JSX.Element; @@ -36,7 +35,6 @@ export interface renderTabBarProperties { } interface ScrollableTabViewProperties extends React.Props { - /** * tabBarPosition (String) Defaults to "top". * "bottom" to position the tab bar below content. @@ -61,13 +59,13 @@ interface ScrollableTabViewProperties extends React.Props { * an Object containing two keys: i: the index of the tab that is selected, ref: the ref of the * tab that is selected */ - onChangeTab?: (value: onChangeTabProperties) => void; + onChangeTab?(value: onChangeTabProperties): void; /** * onScroll (Function) - function to call when the pages are sliding, * should accept 1 argument which is an Float number representing the page position in the slide frame. */ - onScroll?: (value: number) => void; + onScroll?(value: number): void; /** * renderTabBar (Function:ReactComponent) - accept 1 argument props and should return a component @@ -75,7 +73,7 @@ interface ScrollableTabViewProperties extends React.Props { * and should implement setAnimationValue to be able to animate itself along with the tab content. * You can manually pass the props to the TabBar component. */ - renderTabBar?: (value: JSX.Element) => JSX.Element; + renderTabBar?(value: JSX.Element): JSX.Element; /** * style (View.propTypes.style) diff --git a/types/react-native-scrollable-tab-view/react-native-scrollable-tab-view-tests.tsx b/types/react-native-scrollable-tab-view/react-native-scrollable-tab-view-tests.tsx index 2d79537221..0fb10a4ffb 100644 --- a/types/react-native-scrollable-tab-view/react-native-scrollable-tab-view-tests.tsx +++ b/types/react-native-scrollable-tab-view/react-native-scrollable-tab-view-tests.tsx @@ -22,7 +22,6 @@ class MyText extends React.Component { } class ScrollableTabViewDemo extends React.Component<{}, {}> { - constructor(props: ScrollableTabViewDemo) { super(props); } @@ -42,4 +41,4 @@ class ScrollableTabViewDemo extends React.Component<{}, {}> { protected componentWillUnmount?(): void { } -} \ No newline at end of file +} diff --git a/types/react-native-swiper/index.d.ts b/types/react-native-swiper/index.d.ts index f41a771caf..81888289b8 100644 --- a/types/react-native-swiper/index.d.ts +++ b/types/react-native-swiper/index.d.ts @@ -10,7 +10,6 @@ import { } from 'react-native'; interface SwiperProperties extends React.Props { - horizontal?: boolean; style?: ViewStyle; @@ -49,7 +48,7 @@ interface SwiperProperties extends React.Props { index?: number; - renderPagination?: (index: number, total: number, thisObject: Swiper) => JSX.Element; + renderPagination?(index: number, total: number, thisObject: Swiper): JSX.Element; dotStyle?: ViewStyle; @@ -62,4 +61,3 @@ interface SwiperProperties extends React.Props { export default class Swiper extends React.Component { } - diff --git a/types/react-native-swiper/react-native-swiper-tests.tsx b/types/react-native-swiper/react-native-swiper-tests.tsx index fa214e18f0..7463ac0b70 100644 --- a/types/react-native-swiper/react-native-swiper-tests.tsx +++ b/types/react-native-swiper/react-native-swiper-tests.tsx @@ -7,7 +7,6 @@ import { } from 'react-native'; import Swiper from 'react-native-swiper'; - class SwiperTest extends React.Component<{}, {}> { constructor(props: {}) { super(props); @@ -60,4 +59,4 @@ const styles = StyleSheet.create({ fontSize: 30, fontWeight: 'bold' } as ViewStyle -}); \ No newline at end of file +}); diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index 6a833a4467..3742bf5003 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -337,7 +337,8 @@ export interface NativeMethodsMixinStatic { } // see react-jsx.d.ts -export function createElement

(type: React.ReactType, +export function createElement

( + type: React.ReactType, props?: P, ...children: React.ReactNode[]): React.ReactElement

; @@ -1230,7 +1231,7 @@ interface TextInputState { * Unfocuses the specified text field * noop if it wasn't focused */ - blurTextInput(textFieldID?: number) : void + blurTextInput(textFieldID?: number): void } /** @@ -4165,7 +4166,7 @@ export interface LeftToRightGesture { direction: string; } -export interface JumpGesture extends LeftToRightGesture{ +export interface JumpGesture extends LeftToRightGesture { overswipe: { frictionConstant: number frictionByDistance: number @@ -5774,7 +5775,7 @@ export interface SnapshotViewIOSProperties extends ViewProperties, React.Props } @@ -7288,7 +7289,7 @@ export interface EasingStatic { inOut(easing: EasingFunction): EasingFunction; } -export module Animated { +export namespace Animated { // Most (all?) functions where AnimatedValue is used any subclass of Animated can be used as well. type AnimatedValue = Animated; type AnimatedValueXY = ValueXY; @@ -7549,7 +7550,7 @@ export module Animated { * Spring animation based on Rebound and Origami. Tracks velocity state to * create fluid motions as the `toValue` updates, and can be chained together. */ - export function spring ( + export function spring( value: AnimatedValue | AnimatedValueXY, config: SpringAnimationConfig ): CompositeAnimation; @@ -7563,7 +7564,7 @@ export module Animated { * of the animations is stopped, they will all be stopped. You can override * this with the `stopTogether` flag. */ - export function parallel ( + export function parallel( animations: Array, config?: ParallelConfig ): CompositeAnimation; @@ -7589,7 +7590,7 @@ export module Animated { * ]), *``` */ - export function event ( + export function event( argMapping: Mapping[], config?: EventConfig ): (...args: any[]) => void; @@ -7597,7 +7598,7 @@ export module Animated { /** * Make any React component Animatable. Used to create `Animated.View`, etc. */ - export function createAnimatedComponent (component: any) : any; + export function createAnimatedComponent(component: any): any; /** * Animated variants of the basic native views. Accepts Animated.Value for diff --git a/types/react-native/test/animated.tsx b/types/react-native/test/animated.tsx index 3b3457384c..8efd5fd171 100644 --- a/types/react-native/test/animated.tsx +++ b/types/react-native/test/animated.tsx @@ -90,4 +90,4 @@ function TestAnimatedAPI() { ); -} \ No newline at end of file +} diff --git a/types/react-native/test/index.tsx b/types/react-native/test/index.tsx index f7a4abae57..575693211e 100644 --- a/types/react-native/test/index.tsx +++ b/types/react-native/test/index.tsx @@ -28,19 +28,12 @@ import { } from 'react-native'; function testDimensions() { - var { + const { width, height, scale, fontScale, - } = Dimensions.get("window"); - - var { - width, - height, - scale, - fontScale, - } = Dimensions.get("screen"); + } = Dimensions.get(1 === 1 ? "window" : "screen"); } BackAndroid.addEventListener("hardwareBackPress", () => { @@ -52,7 +45,7 @@ interface LocalStyles { instructions: TextStyle; } -var styles = StyleSheet.create( +const styles = StyleSheet.create( { container: { flex: 1, @@ -97,7 +90,6 @@ const stylesAlt = StyleSheet.create( class Welcome extends React.Component { - refs: { [key: string]: any rootView: View @@ -113,7 +105,6 @@ class Welcome extends React.Component { } render() { - return ( @@ -135,7 +126,7 @@ export default Welcome; // App State -function appStateListener(state : string) { +function appStateListener(state: string) { console.log('New state: ' + state); } diff --git a/types/react-native/tslint.json b/types/react-native/tslint.json index 8ca9d9f2c3..b58d132131 100644 --- a/types/react-native/tslint.json +++ b/types/react-native/tslint.json @@ -2,6 +2,19 @@ "extends": "../tslint.json", "rules": { // Lowercase `object` is available in TypeScript 2.2 only. - "ban-types": false + "ban-types": false, + // Below are all TODO + "array-type": false, + "comment-format": false, + "interface-over-type-literal": false, + "no-misused-new": false, + "no-consecutive-blank-lines": false, + "no-empty-interface": false, + "no-padding": false, + "no-redundant-modifiers": false, + "no-var": false, + "prefer-declare-function": false, + "prefer-method-signature": false, + "semicolon": false } }