Skip to content

Fix various typing issues #1291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion generatedTypes/components/button/ButtonTypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ImageStyle, TextStyle, StyleProp } from 'react-native';
import { BaseComponentInjectedProps, ForwardRefInjectedProps, TypographyModifiers, ColorsModifiers, BackgroundColorModifier, MarginModifiers } from '../../commons/new';
import { TouchableOpacityProps } from '../touchableOpacity';
import { TextProps } from '../text';
import { ImageProps } from '../image';
export declare enum ButtonSize {
xSmall = "xSmall",
small = "small",
Expand All @@ -25,7 +26,7 @@ export declare type ButtonProps = TouchableOpacityProps & TypographyModifiers &
/**
* Icon image source or a callback function that returns a source
*/
iconSource?: object | number | Function;
iconSource?: ImageProps['source'] | Function;
/**
* Icon image style
*/
Expand Down
1,848 changes: 1,828 additions & 20 deletions generatedTypes/components/button/index.d.ts

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions generatedTypes/components/card/CardSection.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export declare type CardSectionProps = ViewProps & {
/**
* Other image props that will be passed to the image
*/
imageProps?: ImageProps;
imageProps?: Partial<ImageProps>;
};
declare const _default: React.ComponentClass<ViewProps & {
/**
Expand Down Expand Up @@ -76,7 +76,7 @@ declare const _default: React.ComponentClass<ViewProps & {
/**
* Other image props that will be passed to the image
*/
imageProps?: ImageProps | undefined;
imageProps?: Partial<ImageProps> | undefined;
} & {
useCustomTheme?: boolean | undefined;
}, any>;
Expand Down
465 changes: 459 additions & 6 deletions generatedTypes/components/text/index.d.ts

Large diffs are not rendered by default.

1,380 changes: 1,368 additions & 12 deletions generatedTypes/incubator/TextField/usePreset.d.ts

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/components/button/ButtonTypes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
} from '../../commons/new';
import {TouchableOpacityProps} from '../touchableOpacity';
import {TextProps} from '../text';
import {ImageProps} from '../image';

export enum ButtonSize {
xSmall = 'xSmall',
Expand Down Expand Up @@ -40,7 +41,7 @@ export type ButtonProps = TouchableOpacityProps &
/**
* Icon image source or a callback function that returns a source
*/
iconSource?: object | number | Function;
iconSource?: ImageProps['source'] | Function;
/**
* Icon image style
*/
Expand Down
2 changes: 1 addition & 1 deletion src/components/card/CardSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export type CardSectionProps = ViewProps & {
/**
* Other image props that will be passed to the image
*/
imageProps?: ImageProps;
imageProps?: Partial<ImageProps>;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This: imageProps?: Omit<ImageProps, 'source' | 'style'>; feels a bit more accurate, WDYT?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really, technically you can also pass source in imageProps and it will work

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, but I'm not sure it's intentional, approving

};

type Props = CardSectionProps & asCardChildProps;
Expand Down
5 changes: 3 additions & 2 deletions src/components/text/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, {PureComponent} from 'react';
import {Text as RNText, StyleSheet, TextProps as RNTextProps, TextStyle, Animated} from 'react-native';
import {Text as RNText, StyleSheet, TextProps as RNTextProps, TextStyle, Animated, StyleProp} from 'react-native';
import _ from 'lodash';
import {
asBaseComponent,
Expand All @@ -12,7 +12,7 @@ import {
} from '../../commons/new';
import {Colors} from 'style';

export type TextProps = RNTextProps & TypographyModifiers & ColorsModifiers & MarginModifiers & {
export type TextProps = Omit<RNTextProps, 'style'> & TypographyModifiers & ColorsModifiers & MarginModifiers & {
/**
* color of the text
*/
Expand All @@ -38,6 +38,7 @@ export type TextProps = RNTextProps & TypographyModifiers & ColorsModifiers & Ma
*/
animated?: boolean;
textAlign?: string;
style?: StyleProp<TextStyle | Animated.AnimatedProps<TextStyle>>;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to Omit<RNTextProps, 'style'> in TextProps

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, weirdly it didn't throw an error on that, anyway fixed it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should move more screens to tsx (found it there)

}
export type TextPropTypes = TextProps; //TODO: remove after ComponentPropTypes deprecation;

Expand Down