Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,42 @@ pub fn default_module_type_provider(module_name: &str) -> Option<TypeConfig> {
})),

"@tanstack/react-virtual" => Some(TypeConfig::Object(ObjectTypeConfig {
properties: Some(IndexMap::from_iter([(
"useVirtualizer".to_string(),
TypeConfig::Hook(HookTypeConfig {
positional_params: Some(Vec::new()),
rest_param: Some(Effect::Read),
return_type: Box::new(TypeConfig::TypeReference(TypeReferenceConfig {
name: BuiltInTypeRef::Any,
})),
return_value_kind: None,
no_alias: None,
aliasing: None,
known_incompatible: Some(
"TanStack Virtual's `useVirtualizer()` API returns functions that cannot be memoized safely".to_string(),
),
}),
)])),
properties: Some(IndexMap::from_iter([
(
"useVirtualizer".to_string(),
TypeConfig::Hook(HookTypeConfig {
positional_params: Some(Vec::new()),
rest_param: Some(Effect::Read),
return_type: Box::new(TypeConfig::TypeReference(TypeReferenceConfig {
name: BuiltInTypeRef::Any,
})),
return_value_kind: None,
no_alias: None,
aliasing: None,
known_incompatible: Some(
"TanStack Virtual's `useVirtualizer()` API returns functions that cannot be memoized safely".to_string(),
),
}),
),
// `useWindowVirtualizer()` wraps the same virtualizer instance as `useVirtualizer()`,
// so its return value is incompatible for the same reason.
(
"useWindowVirtualizer".to_string(),
TypeConfig::Hook(HookTypeConfig {
positional_params: Some(Vec::new()),
rest_param: Some(Effect::Read),
return_type: Box::new(TypeConfig::TypeReference(TypeReferenceConfig {
name: BuiltInTypeRef::Any,
})),
return_value_kind: None,
no_alias: None,
aliasing: None,
known_incompatible: Some(
"TanStack Virtual's `useWindowVirtualizer()` API returns functions that cannot be memoized safely".to_string(),
),
}),
),
])),
})),

_ => None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,17 @@ export function defaultModuleTypeProvider(
returnType: {kind: 'type', name: 'Any'},
knownIncompatible: `TanStack Virtual's \`useVirtualizer()\` API returns functions that cannot be memoized safely`,
},
/*
* `useWindowVirtualizer()` wraps the same virtualizer instance as `useVirtualizer()`, so its return value
* is incompatible for the same reason and we mark the entire hook as incompatible
*/
useWindowVirtualizer: {
kind: 'hook',
positionalParams: [],
restParam: Effect.Read,
returnType: {kind: 'type', name: 'Any'},
knownIncompatible: `TanStack Virtual's \`useWindowVirtualizer()\` API returns functions that cannot be memoized safely`,
},
},
};
}
Expand Down
Loading