I have always associated 'unknown' with the concept of 'not sure,' and when I need to work with it, I believe the type should be narrowed down.
However, in this scenario, it does not behave as expected. Surprisingly, there is no error displayed by the following piece of code:
abstract class Foo<T> {
abstract doth(input: T): void;
}
function checkAndDo(foo: Foo<unknown>) {
const someRandomBS = 'afafaf';
foo.doth(someRandomBS);
}
How can I define the type of checkAndDo
's foo
parameter to convey the idea: "I acknowledge it's a Foo, but I'm uncertain about the generic type parameter"?