Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ npmPreapprovedPackages:
- 'babel-plugin-syntax-hermes-parser'
- 'hermes-parser'
- 'hermes-estree'
- 'tstyche'

tsEnableAutoTypes: false

Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"lint:workspaces": "yarn workspaces foreach --all --exclude \"react-native-reanimated-monorepo\" --parallel --topological-dev run lint",
"lint:root": "eslint . --ignore-pattern 'packages/**' --ignore-pattern 'apps/**' --ignore-pattern 'docs/**' && yarn run --top-level oxfmt --check --ignore-path .prettiereslintignore .",
"prepare-vscode": "bash ./scripts/prepare-vscode.sh",
"type:check:tstyche": "tstyche",
"toggle-bundle-mode": "bash ./scripts/toggle-bundle-mode.sh"
},
"devDependencies": {
Expand Down Expand Up @@ -82,6 +83,7 @@
"remark-gfm": "4.0.1",
"remark-mdx": "3.1.0",
"shelljs": "0.10.0",
"tstyche": "7.2.1",
"typescript": "5.9.3"
},
"resolutions": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { describe, expect, test } from 'tstyche';

import { getStaticFeatureFlag } from '..';

describe('getStaticFeatureFlag', () => {
test('accepts a known static feature flag', () => {
expect(getStaticFeatureFlag).type.toBeCallableWith('RUNTIME_TEST_FLAG');
});

test('rejects an unknown feature flag', () => {
expect(getStaticFeatureFlag).type.not.toBeCallableWith('NON_EXISTENT_FLAG');
});
});
10 changes: 0 additions & 10 deletions packages/react-native-reanimated/__typetests__/FeatureFlagTest.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { useRef } from 'react';
import { describe, expect, test } from 'tstyche';

import type Animated from '..';
import {
dispatchCommand,
measure,
scrollTo,
setGestureState,
useAnimatedRef,
} from '..';

describe('measure', () => {
test('accepts an animated ref', () => {
const animatedRef = useAnimatedRef<Animated.View>();
expect(measure).type.toBeCallableWith(animatedRef);
});

test('rejects a plain ref', () => {
const plainRef = useRef<Animated.View>(null);
expect(measure).type.not.toBeCallableWith(plainRef);
});
});

describe('dispatchCommand', () => {
test('accepts an animated ref with a command and args', () => {
const animatedRef = useAnimatedRef<Animated.View>();
expect(dispatchCommand).type.toBeCallableWith(
animatedRef,
'command',
[1, 2, 3]
);
});

test('works without command arguments', () => {
const animatedRef = useAnimatedRef<Animated.View>();
expect(dispatchCommand).type.toBeCallableWith(animatedRef, 'command');
});

test('rejects a plain ref', () => {
const plainRef = useRef<Animated.View>(null);
expect(dispatchCommand).type.not.toBeCallableWith(
plainRef,
'command',
[1, 2, 3]
);
});
});

describe('scrollTo', () => {
test('accepts an animated scroll view ref', () => {
const animatedRef = useAnimatedRef<Animated.ScrollView>();
expect(scrollTo).type.toBeCallableWith(animatedRef, 0, 0, true);
});

test('rejects a plain ref', () => {
const plainRef = useRef<Animated.ScrollView>(null);
expect(scrollTo).type.not.toBeCallableWith(plainRef, 0, 0, true);
});
});

describe('setGestureState', () => {
test('accepts a handler tag and a new state', () => {
expect(setGestureState).type.toBeCallableWith(1, 2);
});
});

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { describe, expect, test } from 'tstyche';

import { useAnimatedReaction, useSharedValue } from '..';

describe('useAnimatedReaction', () => {
test('accepts a prepare and a react function', () => {
const sv = useSharedValue(0);
expect(useAnimatedReaction).type.toBeCallableWith(
() => sv.value,
(value: number) => {
console.log(value);
}
);
});

test('accepts an optional dependency array', () => {
const sv = useSharedValue(0);
expect(useAnimatedReaction).type.toBeCallableWith(
() => sv.value,
(value: number) => {
console.log(value);
},
[]
);
});

test('react receives the previous result', () => {
const sv = useSharedValue(0);
expect(useAnimatedReaction).type.toBeCallableWith(
() => sv.value,
(value: number, previousResult: number | null) => {
console.log(value, previousResult);
}
);
});
});

This file was deleted.

2 changes: 1 addition & 1 deletion packages/react-native-reanimated/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"type:check:src:native": "yarn tsc --noEmit",
"type:check:src:web": "yarn tsc --noEmit --project tsconfig.web.json",
"type:check:app": "yarn workspace common-app type:check",
"type:check:tests": "../../scripts/test-ts.sh __typetests__",
"type:check:tests": "../../scripts/test-ts.sh __typetests__ && yarn run --top-level type:check:tstyche packages/react-native-reanimated/__typetests__",
"type:check:strict": "yarn type:check:strict:src && yarn type:check:strict:app",
"type:check:strict:src": "yarn tsc --noEmit --customConditions react-native-strict-api",
"type:check:strict:app": "yarn workspace common-app type:check:strict",
Expand Down
4 changes: 4 additions & 0 deletions scripts/test-ts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ FILES=()
for path in "${ARGS[@]}"; do
if [ -d "$path" ]; then
for file in "$path"/*.ts "$path"/*.tsx "$path"/*.d.ts; do
# Skip TSTyche type tests; those run via the `tstyche` runner.
case "$file" in
*.tst.ts | *.tst.tsx) continue ;;
esac
if [ -f "$file" ]; then
FILES+=("$file")
fi
Expand Down
4 changes: 4 additions & 0 deletions tstyche.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://tstyche.org/schemas/config.json",
"testFileMatch": ["packages/*/__typetests__/**/*.tst.*"]
}
15 changes: 15 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -28184,6 +28184,7 @@ __metadata:
remark-gfm: "npm:4.0.1"
remark-mdx: "npm:3.1.0"
shelljs: "npm:0.10.0"
tstyche: "npm:7.2.1"
typescript: "npm:5.9.3"
languageName: unknown
linkType: soft
Expand Down Expand Up @@ -32033,6 +32034,20 @@ __metadata:
languageName: node
linkType: hard

"tstyche@npm:7.2.1":
version: 7.2.1
resolution: "tstyche@npm:7.2.1"
peerDependencies:
typescript: ">=5.4"
peerDependenciesMeta:
typescript:
optional: true
bin:
tstyche: dist/bin.js
checksum: 10/42b21eededd6924b2cd271fb9747be50240b881e5a582d32a2e1bd2e575bd0d50d9a454d82e6ca58b7b6b500be02ac117d579d77f70da6c26dd522ca8f3e97a2
languageName: node
linkType: hard

"tsutils@npm:^3.21.0":
version: 3.21.0
resolution: "tsutils@npm:3.21.0"
Expand Down
Loading