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
{{ message }}
Repository navigation
Handle Type parameter 'T' has a circular default. scenario better #52492
The most important thing about this type is the type of the rows property (a single item, not the array type applied to it) returned by the apiCall promise. This type should determine how other functions are on the rest of the type.
Using generics seems like the most reasonable way to handle this, but unfortunately I'm stuck with either manually specifying the generic each time I use this type (which defeats the purpose of relying on apiCall for the type), or just defaulting to any.
What I would like to be able to do is something like this, which means the whole object matching this type will inherit the type of rows[0]:
Even though typescript complains about the second example in my post above, my codebase lit up with some errors which actually helped me.
The below code snippet for example was invalid but got flagged, which again is a good thing:
const updateFn: TableUpdateFn<X> = {
apiCall:... // { rows: Y[], count: number},
selected: (someVar) =>...// do something with someVar, which would be of type X,
...
}
Only problem is that the selected method in the above method errored because someVar became type unknown instead of the type I wanted (type Y)
This issue has been marked as 'Question' and has seen no recent activity. It has been automatically closed for house-keeping purposes. If you're still waiting on a response, questions are usually better suited to stackoverflow or the TypeScript Discord community.
Activity
jpike88 commentedon Jan 30, 2023
Another notes:
Even though typescript complains about the second example in my post above, my codebase lit up with some errors which actually helped me.
The below code snippet for example was invalid but got flagged, which again is a good thing:
Only problem is that the
selectedmethod in the above method errored because someVar became typeunknowninstead of the type I wanted (typeY)typescript-bot commentedon Feb 2, 2023
This issue has been marked as 'Question' and has seen no recent activity. It has been automatically closed for house-keeping purposes. If you're still waiting on a response, questions are usually better suited to stackoverflow or the TypeScript Discord community.