Skip to content

chore: Migrate value, misc, and style-augmentation type tests to TSTyche#9565

Open
MatiPl01 wants to merge 12 commits into
mainfrom
@matipl01/tstyche-values-misc
Open

chore: Migrate value, misc, and style-augmentation type tests to TSTyche#9565
MatiPl01 wants to merge 12 commits into
mainfrom
@matipl01/tstyche-values-misc

Conversation

@MatiPl01

@MatiPl01 MatiPl01 commented May 29, 2026

Copy link
Copy Markdown
Member

Migrates useSharedValue, useDerivedValue, misc, and animatedStyleAugmentation __typetests__ to TSTyche. Stacked on #9557.

useDerivedValue's readonly check uses a message-matched @ts-expect-error.

MatiPl01 and others added 7 commits May 29, 2026 14:51
The __typetests__ suites assert types through tsc failures and ~220
`@ts-expect-error` directives, which match any error on the following line
and give no per-test reporting. Start migrating them to TSTyche, which runs
on the project's own TypeScript and produces named, isolated assertions.

- Add the `tstyche` dev dependency and a `type:check:tstyche` script.
- Add tstyche.config.json scoped to packages/*/__typetests__.
- Convert FeatureFlagTest.tsx to FeatureFlagTest.tst.ts as the first test.
- Make scripts/test-ts.sh skip *.tst.* so the old and new harnesses run
  side by side and files can be migrated one at a time.

Builds on the TSTyche proof of concept from #7727.
Co-authored-by: Tom Mrazauskas <tom@mrazauskas.de>
The 7.2.1 bump could not be installed: the repo's 8-day npm age gate
quarantines it (published 2026-05-27), and the bump left yarn.lock pinned to
4.1.0, which breaks `yarn install --immutable`.

- Add tstyche to npmPreapprovedPackages in .yarnrc.yml.
- Update yarn.lock to TSTyche 7.2.1.
TSTyche v7 changed the default configuration file name from
tstyche.config.json to tstyche.json. Without the rename v7 auto-renames it at
runtime and prints a warning.
CI runs type tests only through each package's `yarn type:check` ->
`type:check:tests`, so the standalone `type:check:tstyche` script left the
.tst.* tests unenforced now that the old harness skips them. Call
`type:check:tstyche`, scoped to the package, from `type:check:tests` so CI
keeps checking them. Scoped by package path to avoid cross-package build
coupling; worklets stays unwired until it has its first .tst.* test.
- useSharedValue: read/write/compound-assignment/set/get/modify compile-checks.
- useDerivedValue: readonly `.value` via a message-matched `@ts-expect-error`;
  the deprecated `.set` stays a compile-check.
- misc: makeMutable/isSharedValue/interpolateColor/Easing callability, Keyframe
  constructability, and the adapter rejection on useAnimatedStyle.
@MatiPl01 MatiPl01 self-assigned this May 29, 2026
Convert the AnimatedStyle augmentation regression suite (coverage for #9328)
from tsc to TSTyche. These are contextual-assignment compile checks - each
`const s: AnimatedStyle<...> = { ... }` must type-check - so they stay as typed
assignments inside `test()` blocks, which TSTyche validates by type-checking
the file. `toBeAssignableTo` is unsuitable here: it infers the object literal
standalone and widens its string literals (e.g. `'allow-discrete'` -> `string`),
which would wrongly reject the augmented-style cases.

Builds on the TSTyche setup and type:check:tests wiring in #9557.
@MatiPl01 MatiPl01 changed the title chore: Migrate value hooks and misc type tests to TSTyche chore: Migrate value, misc, and style-augmentation type tests to TSTyche May 29, 2026
Strengthen the useSharedValue/useDerivedValue tests with explicit TSTyche
assertions rather than relying on compile-only checks:

- useSharedValue: `toBe<SharedValue<T>>` on the hook return, `toBe<number>` on
  `.value`/`.get()`, `toBeCallableWith` on `.set`/`.modify`, plus a writability
  compile-check (no matcher exists for "writable").
- useDerivedValue: `toBe<DerivedValue<number>>` on the return and `toBe<number>`
  on `.value`, keeping the message-matched readonly `@ts-expect-error`.
Comment thread packages/react-native-reanimated/__typetests__/useDerivedValueTest.tst.ts Outdated
Comment thread packages/react-native-reanimated/__typetests__/useDerivedValueTest.tst.ts Outdated
MatiPl01 and others added 3 commits May 30, 2026 11:24
…Test.tst.ts

Co-authored-by: Tom Mrazauskas <tom@mrazauskas.de>
…Test.tst.ts

Co-authored-by: Tom Mrazauskas <tom@mrazauskas.de>
oxfmt 0.45.0 wraps a multi-line generic type argument differently on its
linux (CI) and darwin bindings, so CI flagged useDerivedValueTest formatting
that passed locally. Bind the hook results to a const so each `toBe<...>()`
fits on one line - no wrap, so it formats identically across platforms.
Base automatically changed from @matipl01/typetests-tstyche to main June 10, 2026 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants