-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Typescript #734
Typescript #734
Conversation
@Titozzz This is looking great, kudos to you 👍 The only issue is that some of the code styling rules you've used are absolute no-go's for us — the rules we use are opinionated and enforced company-wide. Particularly:
Apart from that, excellent job so far! Can you tell me why you've removed the eslint file? |
I just aligned the repo to the default config from eslint community. No problem, I'll update it back |
I tried reverting to your config + adding some typescript defaults. Lemme know if that need any more changes |
I've made sure the example works, let me know if I need to test more |
@Titozzz Amazing work, thank you so much 🙏 I'll set aside some time this weekend to review it in length. Anything particular I should know about using https://github.com/react-native-community/bob? |
Nope it's just used in the prepare phase to build the code |
src/parallaximage/ParallaxImage.tsx
Outdated
offset: number; | ||
width: number; | ||
height: number; | ||
status: 1 | 2 | 3 | 4; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can also define the types of these numbers. It will be easy to understand when someone is trying to use it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried being as precise as I could and 1|2|3|4 is usable by a function expecting number but it's also more clear
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm ok with keeping the numbers as is. However we should probably copy the following comment there as well for clarity's sake:
// 1 -> loading | 2 -> loaded | 3 -> transition finished | 4 -> error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can probably replace with an enum. That'll make things easier
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Titozzz Great idea!
src/pagination/Pagination.tsx
Outdated
activeDotIndex: number; | ||
dotsLength: number; | ||
activeOpacity?: number; | ||
carouselRef?: Carousel<unknown> | null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
carouselRef?: Carousel<any> | null;
I think we can replace unknown
with any
. Please share your thoughts regarding this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried avoiding all "any's". I suppose I could also template this so that it would be TData if you prefer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Titozzz Let's go with TData
if you don't mind :-)
src/parallaximage/ParallaxImage.tsx
Outdated
import type Carousel from 'src/carousel/Carousel'; | ||
|
||
type ParallaxImageProps = { | ||
carouselRef: Carousel<unknown> | null; // passed from <Carousel /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I mention above, If we can replace Unknown
with any
. Then please change here also.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same answer as Pagination
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, let's use TData
here as well.
@Titozzz Just went over the whole PR and, as far as I can tell, you've done an astounding job! Thank you so much 🙏 Let me know once you're done with the really minor corrections and then... Let's get this merged! PS — Thanks a lot @narender2031 for your thorough review 🙂 |
Hey guys, I would like to test this. Currently I have Maybe with the last commit hash? 🤔 Thank you |
@nelsonprsousa You can target any commit of the repo with its SHA. Here's an example with this PR's current latest commit: "react-native-snap-carousel": "https://github.com/archriss/react-native-snap-carousel#e719467" |
Seems to work with your fork. However, once I Here's my package.json: https://gist.github.com/nelsonprsousa/61ef81bdddc0823bb9ec793924d4c22b Do you know if this is a local related problem? |
@nelsonprsousa Fixed it, thanks :) I uploaded a packed version if you want to try it out just download and you can add it with yarn add "path" @bd-arc @narender2031 fixes are done, can't do many tests as I don't have a good connection here, but should be just fine. |
Now I could add it 👍 I was also expecting to have types with the migration to TypeScript. Am I missing something here? Maybe we need to do something else? Nevertheless the runtime app looks 👌 |
Thanks for testing, I fcked up the path to the d.ts file 🙄 , now it is fixed @nelsonprsousa Feel free to edit the package.json if you don't wanna reinstall 😛 |
Types are now working 👌 Awesome job! 🚀 Just find it hard to compile it without any error 😅 This is my code: const renderItem = (baseData: {
index: number;
dataIndex: number;
item: IPointOfSale;
}): ReactNode => (
<Card
title={baseData.item.title}
subtitle={baseData.item.subtitle}
imagePath={baseData.item.imagePath}
width={96}
height={25}
onPress={navigate(navigation, baseData.item.navigation)}
/>
);
<Carousel
ref={carouselRef}
data={pointsOfSale}
renderItem={renderItem}
onScrollIndexChanged={setActiveSlide}
sliderWidth={theme.mixins.width}
itemWidth={theme.mixins.width}
hasParallaxImages
containerCustomStyle={{
overflow: 'visible',
marginLeft: theme.mixins.widthPercentageToDP(2),
}}
inactiveSlideScale={0.65}
inactiveSlideOpacity={0.35}
/> But I am getting this: Maybe the problem is the item's type? 🤔 |
I'll do some tests and come back at you |
I need to push a few fixes to parallax image,but then yeah we should merge |
@Titozzz Can't thank you enough for your amazing work on this one 👍 @nelsonprsousa That's exactly the plan! As soon as @Titozzz tells me it's ready, I'll publish a new release :-) |
I've had to make a few key changes to make sure types would be as close to reality as they needed to be.
That's the easy way.
Which is more accurate, and doesn't allow for user error. There are plenty of things I'd like to go over but this PR has waited enough and code is working fine as is. Unless anyone comments otherwise, has bugs, this is READY TO MERGE @bd-arc |
This is superb! I'll do a few more tests and will most certainly merge and publish your PR tomorrow. Thank you for your awesome job on this one @Titozzz 👍 |
Can't wait to get some feedbacks on this. I'm playing with reanimated 2 right now |
@Titozzz Merged and published! Two observations:
|
@bd-arc Any way we can chat, other that using github issues ? :) |
#750 for 1) |
I noticed that the Carousel component is missing some props from "InheritedPropsFromFlatlist", namely extraData which I required on my component when the size changes (lets say a photo finishes uploading). Should I make a separate ticket for that? |
I was looking at this again. Few things:
Is there another way I should be looking at getting typescript support for 4.0.0-beta? |
@Aryk Thanks for the feedback! @Titozzz did an amazing job migrating everything to TypeScript, but we know that a few things probably need some fine-tuning. You're more than welcome to update the Typescript definition and submit a PR if you feel like it. Just make sure to ping me when you do so or I'm probably going to miss it. |
There is definitely a big need for polishing. I'll try fixing this in the next weeks |
2 'bugs' might have been fixed btw
Platforms affected
What does this PR do?
What testing has been done on this change?
Tested features checklist
enableMomentum
)vertical
)activeSlideAlignment
)autoplay
)loop
)ScrollView
/FlatList
carousels (propuseScrollView
)ParallaxImage
componentPagination
component