mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 14:20:12 +00:00
[react-native] fixes StyleSheet.flatten use caused by StyleSheet.compose definition (#41408)
This commit is contained in:
committed by
Eloy Durán
parent
1b29bd026a
commit
32f58bbeea
6
types/react-native/index.d.ts
vendored
6
types/react-native/index.d.ts
vendored
@@ -1963,10 +1963,10 @@ export interface ViewPropsAndroid {
|
||||
}
|
||||
|
||||
type Falsy = undefined | null | false;
|
||||
interface RecursiveArray<T> extends Array<T | RecursiveArray<T>> {}
|
||||
interface RecursiveArray<T> extends Array<T | ReadonlyArray<T> | RecursiveArray<T>> {}
|
||||
/** Keep a brand of 'T' so that calls to `StyleSheet.flatten` can take `RegisteredStyle<T>` and return `T`. */
|
||||
type RegisteredStyle<T> = number & { __registeredStyleBrand: T };
|
||||
export type StyleProp<T> = T | RegisteredStyle<T> | ReadonlyArray<T> | RecursiveArray<T | RegisteredStyle<T> | Falsy> | Falsy;
|
||||
export type StyleProp<T> = T | RegisteredStyle<T> | RecursiveArray<T | RegisteredStyle<T> | Falsy> | Falsy;
|
||||
|
||||
/**
|
||||
* @see https://facebook.github.io/react-native/docs/accessibility.html#accessibility-properties
|
||||
@@ -5136,7 +5136,7 @@ export namespace StyleSheet {
|
||||
* an array, saving allocations and maintaining reference equality for
|
||||
* PureComponent checks.
|
||||
*/
|
||||
export function compose<T>(style1: StyleProp<T>, style2: StyleProp<T>): StyleProp<T>;
|
||||
export function compose<T>(style1: StyleProp<T> | Array<StyleProp<T>>, style2: StyleProp<T> | Array<StyleProp<T>>): StyleProp<T>;
|
||||
|
||||
/**
|
||||
* WARNING: EXPERIMENTAL. Breaking changes will probably happen a lot and will
|
||||
|
||||
@@ -187,6 +187,11 @@ const textProperty = StyleSheet.flatten(textStyle).fontSize;
|
||||
const imageProperty = StyleSheet.flatten(imageStyle).resizeMode;
|
||||
const fontVariantProperty = StyleSheet.flatten(fontVariantStyle).fontVariant;
|
||||
|
||||
// correct use of the StyleSheet.flatten
|
||||
const styleArray: StyleProp<ViewStyle>[] = [];
|
||||
const flattenStyle = StyleSheet.flatten(styleArray);
|
||||
const { top } = flattenStyle;
|
||||
|
||||
const s = StyleSheet.create({
|
||||
shouldWork: {
|
||||
fontWeight: "900", // if we comment this line, errors gone
|
||||
|
||||
Reference in New Issue
Block a user