You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is mostly useful for React development. We can have higer order components that might take generic class and return generic class. However deeply nested generics are inferred as unknown type.
Also connect from react-redux shows the same behaviour.
Examples
// Imagine I have generic component like this:classComp<T> extends React.Component<{data: T,width: number}>{}
// and this is my generic function - it takes component and returns component (with one property less)
function WithWidth<Textends{width: number}>(component: React.ComponentType<T>): React.ComponentType<Omit<T, 'width'>>{
...
}// here I want to create component based on Comp, but with one property boundedconstCompWithWidth=WithWidth(Comp);
Suggestion
Please add support for deeply nested generics.
Use Cases
This is mostly useful for React development. We can have higer order components that might take generic class and return generic class. However deeply nested generics are inferred as
unknown
type.Also
connect
fromreact-redux
shows the same behaviour.Examples
In that example
CompWithWidth
has type:so
data
is no longer generic parameter. It isunknown
from now on.Checklist
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: