-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
Remove react-native-reanimated.d.ts #4519
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Thanks for submitting a pull request! We appreciate you spending the time to work on these changes. Please follow the template so that the reviewers can easily understand what the code changes affect. --> ## Summary The `FrameInfo` interface was not being exported out of the package, although it's present in the old `.d.ts` file, this PR adds the missing export.
## Description This PR is part of an ongoing effort to get rid of the `.d.ts` file and use type definitions generated based on the source code. ## Changes - Changed `measure` to be a generic function - Changed `scrollTo` to be a generic function ## Checklist - [x] Included code example that can be used to test this change - [x] Updated TS types - [x] Added TS types tests - [ ] Added unit / integration tests - [ ] Updated documentation - [ ] Ensured that CI passes --------- Co-authored-by: Tomasz Żelawski <tomasz.zelawski@swmansion.com> Co-authored-by: Tomasz Żelawski <40713406+tjzel@users.noreply.github.com>
## Description This PR is part of an ongoing effort to get rid of `.d.ts` file and use type definitions generated based on the source files. ## Changes - Update exported FlatList type to be generic - Export type and the component under the same name ## Checklist - [ ] Included code example that can be used to test this change - [ ] Updated TS types - [ ] Added TS types tests - [ ] Added unit / integration tests - [ ] Updated documentation - [ ] Ensured that CI passes --------- Co-authored-by: Tomasz Żelawski <40713406+tjzel@users.noreply.github.com>
## Description This PR is a part of the ongoing effort to get rid of Reanimated's `.d.ts` file and switch to types generated based on the source code. ## Changes - Updated types of `useAnimatedGestureHandler` types to be compatible with the ones present in the `.d.ts` ## Checklist - [ ] Updated TS types - [ ] Included code example that can be used to test this change - [ ] Added TS types tests - [ ] Added unit / integration tests - [ ] Updated documentation - [ ] Ensured that CI passes
## Description This PR is part of an ongoing effort to get rid of the `.d.ts` file and switch to types generated based on the source code. ## Changes - Updated `AnimatedStyle` to allow primitives for certain props - Updated `useAnimatedStyle` to not accept functions returning arrays ## Checklist - [ ] Included code example that can be used to test this change - [ ] Updated TS types - [ ] Added TS types tests - [ ] Added unit / integration tests - [ ] Updated documentation - [ ] Ensured that CI passes
<!-- Thanks for submitting a pull request! We appreciate you spending the time to work on these changes. Please follow the template so that the reviewers can easily understand what the code changes affect. --> ## Summary This PR is part of an ongoing effort to get rid of `.d.ts` file and use type definitions generated based on the source files. In this case, I've changed `AnimatedSensor` to be generic and provide different sensors depending on what it's parametrized with. This way it's easy to overload `useAnimatedSensor` and setup the correct typings depending on what sensor is being created. --------- Co-authored-by: Tomasz Żelawski <tomasz.zelawski@swmansion.com>
<!-- Thanks for submitting a pull request! We appreciate you spending the time to work on these changes. Please follow the template so that the reviewers can easily understand what the code changes affect. --> ## Summary This PR is part of an ongoing effort to get rid of `.d.ts` file and use type definitions generated based on the source files. The focus of this PR is on the code responsible for building layout animations. Instead of hard-coded return types in builders, it uses the implicit `this` argument to infer the type that should be returned.
<!-- Thanks for submitting a pull request! We appreciate you spending the time to work on these changes. Please follow the template so that the reviewers can easily understand what the code changes affect. --> ## Summary This PR is part of an ongoing effort to get rid of `.d.ts` file and use type definitions generated based on the source files. The main focus of this PR is to make `withDelay` and `withRepeat` generic functions so that they can accept any animation as an argument instead of only their own type. ## Test plan <!-- Provide a minimal but complete code snippet that can be used to test out this change along with instructions how to run it and a description of the expected behavior. -->
Latropos
approved these changes
Jun 27, 2023
piaskowyk
reviewed
Jun 27, 2023
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.
- const output = [];
+ const output: JSX.Element[] = [];
I think it's better to fix these changes in separate PR, not to bloat this one more. |
This was referenced Jun 30, 2023
Closed
github-merge-queue bot
pushed a commit
that referenced
this pull request
Jul 2, 2023
<!-- Thanks for submitting a pull request! We appreciate you spending the time to work on these changes. Please follow the template so that the reviewers can easily understand what the code changes affect. --> ## Summary `const IS_WEB = isWeb();` was accidentaly moved inside the `'worklet'` function in this [PR](#4519) on `decay.ts` This PR moves it outside the `'worket'` function. Fixes: #4656 Co-authored-by: Efstathios Ntonas <stathis@hikiapp.com>
Latropos
pushed a commit
that referenced
this pull request
Jul 3, 2023
## Motivation Since React Native Reanimated started as a pure JavaScript library at some point it was decided to migrate to TypeScript. Code base was complex enough for this task to be difficult and automatically generated type definitions weren't coherent with the API. Therefore a manually written file was required to provide better types for people that use TypeScript. However this created problems on its own as not all of the changes were put into the `d.ts` file and differences between inferred type and manual type could be very significant. After time we circled back to complete the TypeScript migration and remove this intermediate `d.ts` file. ## Summary The goal of this PR is to remove `react-native-reanimated.d.ts` file that had all of our manually written type definitions in favor of automatically generated files stemming from source files. Since this was still a strenuous task we've decided not to fix all the internal types just yet and preserve only the necessary manually written types from the `d.ts` file. There's quite a lot of type casting due to that but this is planned to be corrected in the future as well. Fixes: #4616, #4556 ## Test plan I've added the following script to our `package.json`: `yarn type:check-api`. It compiles source code of our examples with the use of autogenerated type definitions. It was my main tool of performing this migration an was extremely handy. All of our static check were useful as well - of course linting and type checking the source code. Since our Examples don't cover all of the cases of our API usage (although I believe they cover a significant part of it) and we've kept as little of the `d.ts` file as possible it's to be expected for type errors to be reported in the future - but I think it's the better way to do it than to attempt to generate more API use cases by us. --------- Co-authored-by: Krzysztof Piaskowy <krzysztof.piaskowy@swmansion.com> Co-authored-by: Karol Wąsowski <karol.wasowski@swmansion.com> Co-authored-by: Tomek Zawadzki <tomekzawadzki98@gmail.com> Co-authored-by: Jakub Piasecki <jakub.piasecki@swmansion.com> Co-authored-by: Jakub Piasecki <jakubpiasecki67@gmail.com>
Latropos
pushed a commit
that referenced
this pull request
Jul 3, 2023
<!-- Thanks for submitting a pull request! We appreciate you spending the time to work on these changes. Please follow the template so that the reviewers can easily understand what the code changes affect. --> ## Summary `const IS_WEB = isWeb();` was accidentaly moved inside the `'worklet'` function in this [PR](#4519) on `decay.ts` This PR moves it outside the `'worket'` function. Fixes: #4656 Co-authored-by: Efstathios Ntonas <stathis@hikiapp.com>
github-merge-queue bot
pushed a commit
that referenced
this pull request
Jul 5, 2023
## Summary Added as discussed in #4519. All changes in file except for `.eslint.rc` were made automatically by `eslint --fix` and `yarn format`.
Latropos
pushed a commit
that referenced
this pull request
Jul 13, 2023
## Summary Added as discussed in #4519. All changes in file except for `.eslint.rc` were made automatically by `eslint --fix` and `yarn format`.
This was referenced Jul 26, 2023
Merged
github-merge-queue bot
pushed a commit
that referenced
this pull request
Aug 4, 2023
<!-- Thanks for submitting a pull request! We appreciate you spending the time to work on these changes. Please follow the template so that the reviewers can easily understand what the code changes affect. --> ## Summary During removal of `react-native-reanimated.d.ts` in #4519 I didn't consider that some types were exported only in the aforementioned file, e.g. `WithSpringConfig`. Therefore when we released `3.4.0` those types disappear from public API. This PR restores lacking types from `.d.ts` - but only the relevant ones, without Reanimated1 API. ## Types restored ### namespace Animated - Extrapolate - DerivedValue - Adaptable - TransformStyleTypes - AdaptTransforms - AnimatedTransform - AnimateStyle - StylesOrDefault - AnimateProps - EasingFunction - addWhitelistedNativeProps - addWhitelistedUIProps - AnimatedScrollViewProps - FlatListPropsWithLayout ### react-native-reanimated - Adaptable - AdaptTransforms - AnimatedTransform - TransformStyleTypes - AnimateStyle - StylesOrDefault - AnimatedScrollViewProps - FlatListPropsWithLayout - \-\-\- - EasingFunction - EasingFunctionFactory - \-\-\- - WithDecayConfig - \-\-\- - WithSpringConfig - \-\-\- - WithTimingConfig - \-\-\- - FlatListPropsWithLayout - \-\-\- - AnimatedScrollViewProps - \-\-\- - AnimatedStyleProp - \-\-\- - InterpolateRGB - InterpolateHSV - \-\-\- - KeyframeProps ___ Requires #4855 ## Test plan CI + 🚀
piaskowyk
pushed a commit
that referenced
this pull request
Aug 4, 2023
<!-- Thanks for submitting a pull request! We appreciate you spending the time to work on these changes. Please follow the template so that the reviewers can easily understand what the code changes affect. --> ## Summary During removal of `react-native-reanimated.d.ts` in #4519 I didn't consider that some types were exported only in the aforementioned file, e.g. `WithSpringConfig`. Therefore when we released `3.4.0` those types disappear from public API. This PR restores lacking types from `.d.ts` - but only the relevant ones, without Reanimated1 API. ## Types restored ### namespace Animated - Extrapolate - DerivedValue - Adaptable - TransformStyleTypes - AdaptTransforms - AnimatedTransform - AnimateStyle - StylesOrDefault - AnimateProps - EasingFunction - addWhitelistedNativeProps - addWhitelistedUIProps - AnimatedScrollViewProps - FlatListPropsWithLayout ### react-native-reanimated - Adaptable - AdaptTransforms - AnimatedTransform - TransformStyleTypes - AnimateStyle - StylesOrDefault - AnimatedScrollViewProps - FlatListPropsWithLayout - \-\-\- - EasingFunction - EasingFunctionFactory - \-\-\- - WithDecayConfig - \-\-\- - WithSpringConfig - \-\-\- - WithTimingConfig - \-\-\- - FlatListPropsWithLayout - \-\-\- - AnimatedScrollViewProps - \-\-\- - AnimatedStyleProp - \-\-\- - InterpolateRGB - InterpolateHSV - \-\-\- - KeyframeProps ___ Requires #4855 ## Test plan CI + 🚀
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Since React Native Reanimated started as a pure JavaScript library at some point it was decided to migrate to TypeScript. Code base was complex enough for this task to be difficult and automatically generated type definitions weren't coherent with the API. Therefore a manually written file was required to provide better types for people that use TypeScript. However this created problems on its own as not all of the changes were put into the
d.ts
file and differences between inferred type and manual type could be very significant. After time we circled back to complete the TypeScript migration and remove this intermediated.ts
file.Summary
The goal of this PR is to remove
react-native-reanimated.d.ts
file that had all of our manually written type definitions in favor of automatically generated files stemming from source files. Since this was still a strenuous task we've decided not to fix all the internal types just yet and preserve only the necessary manually written types from thed.ts
file. There's quite a lot of type casting due to that but this is planned to be corrected in the future as well.Fixes: #4616, #4556
Test plan
I've added the following script to our
package.json
:yarn type:check-api
. It compiles source code of our examples with the use of autogenerated type definitions. It was my main tool of performing this migration an was extremely handy.All of our static check were useful as well - of course linting and type checking the source code.
Since our Examples don't cover all of the cases of our API usage (although I believe they cover a significant part of it) and we've kept as little of the
d.ts
file as possible it's to be expected for type errors to be reported in the future - but I think it's the better way to do it than to attempt to generate more API use cases by us.