Skip to content

ScrollBar - TS migration #1078

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 8 commits into from
Dec 28, 2020
Merged

ScrollBar - TS migration #1078

merged 8 commits into from
Dec 28, 2020

Conversation

Inbal-Tish
Copy link
Collaborator

Description

ScrollBar - migrate to TS.

Changelog

ScrollBar - migrate to TS.

Copy link
Collaborator

@ethanshar ethanshar left a comment

Choose a reason for hiding this comment

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

You need to export it also in src/index.ts and in generateTypes/index.d.ts
It's not exported as a stub

@ethanshar
Copy link
Collaborator

@Inbal-Tish
Im getting TS errors locally when I run npm run build:dev
It's weird that the CI still pass green.
Anyway, can you check..

@Inbal-Tish
Copy link
Collaborator Author

Inbal-Tish commented Dec 15, 2020

@ethanshar I know. I have an error on 'forwardedRef.current'...

@Inbal-Tish Inbal-Tish requested a review from ethanshar December 17, 2020 06:22
interface Props extends FlatListProps<any> {
interface Props extends FlatListProps<any>, ForwardRefInjectedProps {
Copy link
Collaborator

Choose a reason for hiding this comment

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

The props you're using for export should not include internal typings like ForwardRefInjectedProps.

ForwardRefInjectedProps typings are internal, we use them because we wrap our component with the forwardRef HOC.

The way we do that is like this:

interface Props {}

type InternalProps = Props & ForwardRefInjectedProps; 


// Here you use "InternalProps" cause you also expecting to get internal props like "forwardedRed", etc.. 
class YourComponent extends Component<InternalProps, State> {}

// Here you use "Props" - this is the API we expose for our users. 
export default asBaseComponent<Props, typeof YourComponent>(forwardRef<Props>(YourComponent));

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So what do I export? If I do this export type ScrollBarProps = Props & ForwardRefInjectedProps; I also export the internal prop, no?

Copy link
Collaborator

@ethanshar ethanshar Dec 28, 2020

Choose a reason for hiding this comment

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

Yes,
See my code snippet.
I break the typings into two Props & InternalProps. Eventually I export Props only

You can also find examples in other components (View, Text, etc..)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

@ethanshar ethanshar merged commit c8d3ed5 into master Dec 28, 2020
M-i-k-e-l added a commit that referenced this pull request Dec 29, 2020
…-component-2

* master:
  export Button enums
  fix typings
  Fix lint issues
  Fix Switch color based props to use ColorValue typing
  Fix manual placeholderTextColor typing for ChipsInput
  Fix manualy typing of ChipsInput for selectionColor prop
  fix @types/react-native version to 0.63.4
  Fix rn63 typings (#1100)
  Revert "fix for tabbar types for scrollbar"
  fix for tabbar types for scrollbar
  ScrollBar - TS migration (#1078)
  TabBar refactor (#1076)
  Update reanimated and gesture-handler to their latest version
  cleanup Cards example screen
  upgraded expo demo app to expo v40 (#1096)
  Update RNN version

# Conflicts:
#	src/components/tabController/TabBar.tsx
@Inbal-Tish Inbal-Tish deleted the infra/ScrollBar_TS_migration branch January 12, 2021 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants