mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
fix: fix animated components ref types (#36472)
Summary: I found Animated components like `View`, `Text`, `ScrollView`, `Image` ref type inferred as `any` when ref callback used.  this is happening because of `unknown` type is included as union type as below.  So I excluded `unknown` type inferring via fixing `TAugmentRef` utility type. Result below!  ## Changelog [GENERAL] [FIXED] - fix animated components ref type inferred `any` <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> Pull Request resolved: https://github.com/facebook/react-native/pull/36472 Test Plan: Ran `yarn test-typescript` and `yarn test-typescript-offline` with no errors. Reviewed By: cipolleschi Differential Revision: D44055510 Pulled By: dmytrorykun fbshipit-source-id: 0d380a2c2198c84d586889e912dec5d2304c213a
This commit is contained in:
committed by
Facebook GitHub Bot
parent
ac5aec3f5c
commit
419b41f06d
Vendored
+3
-1
@@ -564,7 +564,9 @@ export namespace Animated {
|
||||
type NonAnimatedProps = 'key' | 'ref';
|
||||
|
||||
type TAugmentRef<T> = T extends React.Ref<infer R>
|
||||
? React.Ref<R | LegacyRef<R>>
|
||||
? unknown extends R
|
||||
? never
|
||||
: React.Ref<R | LegacyRef<R>>
|
||||
: never;
|
||||
|
||||
export type AnimatedProps<T> = {
|
||||
|
||||
Reference in New Issue
Block a user