From c293017ce15f7a1ec91c443d38bd0722d45809c8 Mon Sep 17 00:00:00 2001 From: Cody Olsen Date: Mon, 15 Sep 2025 15:25:16 +0200 Subject: [PATCH] [compiler]: add `@tanstack/react-virtual` to known incompatible libraries --- .../src/HIR/DefaultModuleTypeProvider.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/compiler/packages/babel-plugin-react-compiler/src/HIR/DefaultModuleTypeProvider.ts b/compiler/packages/babel-plugin-react-compiler/src/HIR/DefaultModuleTypeProvider.ts index 3b3e120f39076..106fce615c44e 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/HIR/DefaultModuleTypeProvider.ts +++ b/compiler/packages/babel-plugin-react-compiler/src/HIR/DefaultModuleTypeProvider.ts @@ -86,6 +86,24 @@ export function defaultModuleTypeProvider( }, }; } + case '@tanstack/react-virtual': { + return { + kind: 'object', + properties: { + /* + * Many of the properties of `useVirtualizer()`'s return value are incompatible, so we mark the entire hook + * as incompatible + */ + useVirtualizer: { + kind: 'hook', + positionalParams: [], + restParam: Effect.Read, + returnType: {kind: 'type', name: 'Any'}, + knownIncompatible: `TanStack Virtual's \`useVirtualizer()\` API returns functions that cannot be memoized safely`, + }, + }, + }; + } } return null; }