-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Remove any from public types #2541
Copy link
Copy link
Open
Labels
area: typescriptTypescript issuesTypescript issueskind: requestNew feature or request that should be actionedNew feature or request that should be actionedrelease: major
Metadata
Metadata
Assignees
Labels
area: typescriptTypescript issuesTypescript issueskind: requestNew feature or request that should be actionedNew feature or request that should be actionedrelease: major
Type
Fields
Give feedbackNo fields configured for issues without a type.
A clear and concise description of what the feature is
Tighten the consumer-facing TypeScript surface — replace accidental
anyon public types (hook return values, handler arguments likeonChange, the values read off a spring) with accurate types, so the API describes what it actually accepts and returns. Scope isanythat leaks into user code, not the deliberate varianceanythe engine relies on internally.Two examples in the code today, both in
packages/core/src/types/props.ts:Why should this feature be included?
Accidental
anyon public surfaces silently switches off type-checking for consumers: no autocomplete, no error when the shape is wrong, no editor guidance. It's a recurring source of user-reported bugs:onChangehandler #2183 —onChangereceives the wrong (any) result type.<Spring>render prop is inferred asany(breaks undernoImplicitAny).onDestroyedis wrong #1114 —onDestroyedtype definition is wrong.useTransitioninference fails when styles are set via functions.Tightening these makes the real public type surface explicit and gives consumers accurate IntelliSense and call-site errors.