I am encountering some difficulties in developing a generic function without using the any
keyword, as it is not recommended by our linter. I attempted to replace it with unknown
or never
since I do not necessarily need to identify the specific type. However, this approach only resulted in different errors.
While I could simply stick with any
and disable our linter for that particular case, I am eager to explore if there is an alternative solution available.
Below is a simplified and modified version of the code for illustrative purposes (TS Playground):
interface DialogContent<TResult> {
close: Subject<TResult>;
}
function showDialog<T extends DialogContent<<any /*what can be used here instead of any */>>(resolver: () => T)
{
//...
}
class ExampleDialogContent implements DialogContent<void>{
close = new Subject<void>();
}
showDialog<ExampleDialogContent>(() => new ExampleDialogContent());