[@types/react-native] Fix: Animated Components are always any type (#41939)

* Fix: Animated Components are always any type

* Update index.d.ts

* Update types/react-native/index.d.ts

Co-Authored-By: Eloy Durán <eloy.de.enige@gmail.com>

* Update index.d.ts

* Update index.d.ts

* Update index.d.ts

* Update index.d.ts

* Fix: Ts Error

* Test: Animated.Image missing source prop

* Type: Animated Value Props

* Update index.d.ts

* Update index.d.ts

* Update index.d.ts

* Type: Bump Minimum TypeScript Version to 3.7

* Update index.d.ts

* Update index.d.ts

* Update index.d.ts

* Fix: no-unnecessary-qualifier

Co-authored-by: Eloy Durán <eloy.de.enige@gmail.com>
This commit is contained in:
Shinpei
2020-01-31 17:28:41 +01:00
committed by GitHub
co-authored by Eloy Durán
parent 7092c0f044
commit f7ba6e840d
2 changed files with 27 additions and 10 deletions
+26 -9
View File
@@ -3994,7 +3994,7 @@ export interface FlatListProps<ItemT> extends VirtualizedListProps<ItemT> {
removeClippedSubviews?: boolean;
}
export class FlatList<ItemT> extends React.Component<FlatListProps<ItemT>> {
export class FlatList<ItemT = any> extends React.Component<FlatListProps<ItemT>> {
/**
* Scrolls to the end of the content. May be janky without `getItemLayout` prop.
*/
@@ -4227,7 +4227,7 @@ export interface SectionListScrollParams {
viewPosition?: number;
}
export class SectionList<SectionT> extends React.Component<SectionListProps<SectionT>> {
export class SectionList<SectionT = any> extends React.Component<SectionListProps<SectionT>> {
/**
* Scrolls to the item at the specified sectionIndex and itemIndex (within the section)
* positioned in the viewable area such that viewPosition 0 places it at the top
@@ -8472,21 +8472,38 @@ export namespace Animated {
*/
export function event<T>(argMapping: Array<Mapping | null>, config?: EventConfig<T>): (...args: any[]) => void;
export type ComponentProps<T> = T extends React.ComponentType<infer P> | React.Component<infer P> ? P : never;
export interface WithAnimatedValue<T>
extends ThisType<
T extends object
? { [K in keyof T]?: WithAnimatedValue<T[K]> }
: T extends (infer P)[]
? WithAnimatedValue<P>[]
: T | Value | AnimatedInterpolation
> {}
export type AnimatedProps<T> = { [key in keyof T]: WithAnimatedValue<T[key]> };
export interface AnimatedComponent<T extends React.ComponentType<ComponentProps<T>> | React.Component<ComponentProps<T>>> extends React.FC<AnimatedProps<ComponentProps<T>>> {
getNode: () => T;
}
/**
* Make any React component Animatable. Used to create `Animated.View`, etc.
*/
export function createAnimatedComponent(component: any): any;
export function createAnimatedComponent<T extends React.ComponentType<ComponentProps<T>> | React.Component<ComponentProps<T>>>(component: T): AnimatedComponent<T extends React.ComponentClass<ComponentProps<T>> ? InstanceType<T> : T>;
/**
* Animated variants of the basic native views. Accepts Animated.Value for
* props and style.
*/
export const View: any;
export const Image: any;
export const Text: any;
export const ScrollView: any;
export const FlatList: any;
export const SectionList: any;
export const View: AnimatedComponent<View>;
export const Image: AnimatedComponent<Image>;
export const Text: AnimatedComponent<Text>;
export const ScrollView: AnimatedComponent<ScrollView>;
export const FlatList: AnimatedComponent<FlatList>;
export const SectionList: AnimatedComponent<SectionList>;
}
// tslint:disable-next-line:interface-name
+1 -1
View File
@@ -84,7 +84,7 @@ function TestAnimatedAPI() {
]}
/>
<Animated.Image style={position.getTranslateTransform()} />
<Animated.Image style={position.getTranslateTransform()} source={{uri: 'https://picsum.photos/200'}} />
</View>
);
}