Skip to content

Commit a38678d

Browse files
authored
Fix TypeScript tests after .d.ts cleanup (#4164)
<!-- 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 <!-- Explain the motivation for this PR. Include "Fixes #<number>" if applicable. --> ## 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. -->
1 parent 027d650 commit a38678d

File tree

3 files changed

+6
-164
lines changed

3 files changed

+6
-164
lines changed

Diff for: .github/workflows/static-example-apps-checks.yml

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
paths:
55
- 'Example/**'
66
- 'FabricExample/**'
7+
- '*'
78
push:
89
branches:
910
- main

Diff for: FabricExample/react-native-reanimated-tests.tsx

-33
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ import Animated, {
3939
useAnimatedReaction,
4040
interpolateColor,
4141
makeMutable,
42-
interpolateNode,
43-
useValue,
44-
color,
45-
interpolateColors,
4642
createAnimatedPropAdapter,
4743
useAnimatedProps,
4844
useAnimatedRef,
@@ -707,35 +703,6 @@ function interpolateColorTest() {
707703
return null;
708704
}
709705

710-
function interpolateNodeTest() {
711-
const value = useValue(0);
712-
interpolateNode(value, {
713-
inputRange: [0, 1],
714-
outputRange: ['0deg', '100deg'],
715-
});
716-
interpolateNode(value, {
717-
inputRange: [0, 1],
718-
outputRange: ['0rad', `${Math.PI}rad`],
719-
});
720-
}
721-
722-
function colorTest() {
723-
const r = useValue(255);
724-
const g = useValue(255);
725-
const b = useValue(255);
726-
const a = useValue(255);
727-
return color(r, g, b, a);
728-
}
729-
730-
function interpolateColorsTest() {
731-
const animationValue = useValue(0);
732-
const color = interpolateColors(animationValue, {
733-
inputRange: [0, 1],
734-
outputColorRange: ['red', 'blue'],
735-
});
736-
return color;
737-
}
738-
739706
// update props
740707
function updatePropsTest() {
741708
const adapter1 = createAnimatedPropAdapter((props) => {}, []);

Diff for: react-native-reanimated.d.ts

+5-131
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ declare module 'react-native-reanimated' {
5757
import('./lib/types/lib/reanimated2/commonTypes').MeasuredDimensions;
5858

5959
namespace Animated {
60-
type Nullable<T> = T | null | undefined;
61-
6260
export enum Extrapolate {
6361
EXTEND = 'extend',
6462
CLAMP = 'clamp',
@@ -80,22 +78,10 @@ declare module 'react-native-reanimated' {
8078

8179
export type SharedValue<T> = { value: T };
8280
export type DerivedValue<T> = Readonly<SharedValue<T>>;
83-
export type Mapping = { [key: string]: Mapping } | Adaptable<any>;
8481
export type Adaptable<T> =
8582
| T
86-
| AnimatedNode<T>
87-
| ReadonlyArray<T | AnimatedNode<T> | ReadonlyArray<T | AnimatedNode<T>>>
83+
| ReadonlyArray<T | ReadonlyArray<T>>
8884
| SharedValue<T>;
89-
type BinaryOperator<T = number> = (
90-
left: Adaptable<number>,
91-
right: Adaptable<number>
92-
) => AnimatedNode<T>;
93-
type UnaryOperator = (value: Adaptable<number>) => AnimatedNode<number>;
94-
type MultiOperator<T = number> = (
95-
a: Adaptable<number>,
96-
b: Adaptable<number>,
97-
...others: Adaptable<number>[]
98-
) => AnimatedNode<T>;
9985

10086
export type TransformStyleTypes = TransformsStyle['transform'] extends
10187
| readonly (infer T)[]
@@ -116,24 +102,15 @@ declare module 'react-native-reanimated' {
116102
? AnimateStyle<S[K]>
117103
: S[K] extends ColorValue | undefined
118104
? S[K] | number
119-
:
120-
| S[K]
121-
| AnimatedNode<
122-
// allow `number` where `string` normally is to support colors
123-
S[K] extends ColorValue | undefined ? S[K] | number : S[K]
124-
>
125-
| SharedValue<AnimatableValue>;
105+
: S[K] | SharedValue<AnimatableValue>;
126106
};
127107

128108
export type StylesOrDefault<T> = 'style' extends keyof T
129109
? T['style']
130110
: Record<string, unknown>;
131111

132112
export type AnimateProps<P extends object> = {
133-
[K in keyof Omit<P, 'style'>]:
134-
| P[K]
135-
| AnimatedNode<P[K]>
136-
| SharedValue<P[K]>;
113+
[K in keyof Omit<P, 'style'>]: P[K] | SharedValue<P[K]>;
137114
} & {
138115
style?: StyleProp<AnimateStyle<StylesOrDefault<P>>>;
139116
} & {
@@ -156,82 +133,6 @@ declare module 'react-native-reanimated' {
156133
sharedTransitionStyle?: ILayoutAnimationBuilder;
157134
};
158135

159-
export interface PhysicsAnimationState extends AnimationState {
160-
velocity: AnimatedValue<number>;
161-
}
162-
163-
export type DecayState = PhysicsAnimationState;
164-
165-
export interface DecayConfig {
166-
deceleration: Adaptable<number>;
167-
}
168-
export interface BackwardCompatibleWrapper {
169-
start: (callback?: (data: { finished: boolean }) => any) => void;
170-
stop: () => void;
171-
}
172-
173-
export interface TimingState extends AnimationState {
174-
frameTime: AnimatedValue<number>;
175-
}
176-
export type EasingNodeFunction = (
177-
value: Adaptable<number>
178-
) => AnimatedNode<number>;
179-
export type EasingFunction = (value: number) => number;
180-
export interface TimingConfig {
181-
toValue: Adaptable<number>;
182-
duration: Adaptable<number>;
183-
easing: EasingNodeFunction;
184-
}
185-
186-
export type SpringState = PhysicsAnimationState;
187-
188-
export interface SpringConfig {
189-
damping: Adaptable<number>;
190-
mass: Adaptable<number>;
191-
stiffness: Adaptable<number>;
192-
overshootClamping: Adaptable<number> | boolean;
193-
restSpeedThreshold: Adaptable<number>;
194-
restDisplacementThreshold: Adaptable<number>;
195-
toValue: Adaptable<number>;
196-
}
197-
interface SpringConfigWithOrigamiTensionAndFriction {
198-
tension: Adaptable<number>;
199-
mass: Adaptable<number>;
200-
friction: Adaptable<number>;
201-
overshootClamping: Adaptable<number> | boolean;
202-
restSpeedThreshold: Adaptable<number>;
203-
restDisplacementThreshold: Adaptable<number>;
204-
toValue: Adaptable<number>;
205-
}
206-
207-
interface SpringConfigWithBouncinessAndSpeed {
208-
bounciness: Adaptable<number>;
209-
mass: Adaptable<number>;
210-
speed: Adaptable<number>;
211-
overshootClamping: Adaptable<number> | boolean;
212-
restSpeedThreshold: Adaptable<number>;
213-
restDisplacementThreshold: Adaptable<number>;
214-
toValue: Adaptable<number>;
215-
}
216-
217-
type SpringUtils = {
218-
makeDefaultConfig: () => SpringConfig;
219-
makeConfigFromBouncinessAndSpeed: (
220-
prevConfig: SpringConfigWithBouncinessAndSpeed
221-
) => SpringConfig;
222-
makeConfigFromOrigamiTensionAndFriction: (
223-
prevConfig: SpringConfigWithOrigamiTensionAndFriction
224-
) => SpringConfig;
225-
};
226-
227-
export const SpringUtils: SpringUtils;
228-
229-
type CodeProps = {
230-
exec?: AnimatedNode<number>;
231-
children?: () => AnimatedNode<number>;
232-
dependencies?: Array<any>;
233-
};
234-
235136
// components
236137
export class View extends Component<AnimateProps<ViewProps>> {
237138
getNode(): ReactNativeView;
@@ -253,8 +154,6 @@ declare module 'react-native-reanimated' {
253154
}
254155
// eslint-disable-next-line @typescript-eslint/no-empty-interface
255156
export interface ScrollView extends ReactNativeScrollView {}
256-
257-
export class Code extends Component<CodeProps> {}
258157
export interface FlatListPropsWithLayout<T> extends FlatListProps<T> {
259158
itemLayoutAnimation?: ILayoutAnimationBuilder;
260159
}
@@ -290,7 +189,6 @@ declare module 'react-native-reanimated' {
290189
export type SharedValue<T> = Animated.SharedValue<T>;
291190
export type AnimateStyle<S> = Animated.AnimateStyle<S>;
292191
export type DerivedValue<T> = Animated.DerivedValue<T>;
293-
export type Mapping = Animated.Mapping;
294192
export type Adaptable<T> = Animated.Adaptable<T>;
295193
export type TransformStyleTypes = Animated.TransformStyleTypes;
296194
export type AdaptTransforms<T> = Animated.AdaptTransforms<T>;
@@ -932,32 +830,6 @@ declare module 'react-native-reanimated' {
932830
export class RollInRight extends ComplexAnimationBuilder {}
933831
export class RollOutLeft extends ComplexAnimationBuilder {}
934832
export class RollOutRight extends ComplexAnimationBuilder {}
935-
interface EasingNodeStatic {
936-
linear: Animated.EasingNodeFunction;
937-
ease: Animated.EasingNodeFunction;
938-
quad: Animated.EasingNodeFunction;
939-
cubic: Animated.EasingNodeFunction;
940-
poly(n: Animated.Adaptable<number>): Animated.EasingNodeFunction;
941-
sin: Animated.EasingNodeFunction;
942-
circle: Animated.EasingNodeFunction;
943-
exp: Animated.EasingNodeFunction;
944-
elastic(
945-
bounciness?: Animated.Adaptable<number>
946-
): Animated.EasingNodeFunction;
947-
back(s?: Animated.Adaptable<number>): Animated.EasingNodeFunction;
948-
bounce: Animated.EasingNodeFunction;
949-
bezier(
950-
x1: number,
951-
y1: number,
952-
x2: number,
953-
y2: number
954-
): Animated.EasingNodeFunction;
955-
in(easing: Animated.EasingNodeFunction): Animated.EasingNodeFunction;
956-
out(easing: Animated.EasingNodeFunction): Animated.EasingNodeFunction;
957-
inOut(easing: Animated.EasingNodeFunction): Animated.EasingNodeFunction;
958-
}
959-
960-
export const EasingNode: EasingNodeStatic;
961833

962834
interface EasingStatic {
963835
linear: Animated.EasingFunction;
@@ -992,6 +864,8 @@ declare module 'react-native-reanimated' {
992864

993865
export function enableLayoutAnimations(flag: boolean): void;
994866

867+
export const Extrapolate: typeof Animated.Extrapolate;
868+
995869
type AnimationFactoryType = (values: LayoutAnimationsValues) => StyleProps;
996870

997871
export class SharedTransition implements ILayoutAnimationBuilder {

0 commit comments

Comments
 (0)