Callionica on Nostr: You can treat `any` as `T` implicitly. You can’t treat `unknown[]` as `T` ...
You can treat `any` as `T` implicitly. You can’t treat `unknown[]` as `T` implicitly. That’s why you need the `as any`.
You could move the `any` into your Map. Otherwise you could tell the compiler that the data you are retrieving from the map is expected to be a T by making your function generic on T and using `as T` instead of `as any`.
Ultimately if you store heterogenous data in the map but don’t use `any` there, you’ll need an explicit cast to get back a specific type.
You could move the `any` into your Map. Otherwise you could tell the compiler that the data you are retrieving from the map is expected to be a T by making your function generic on T and using `as T` instead of `as any`.
Ultimately if you store heterogenous data in the map but don’t use `any` there, you’ll need an explicit cast to get back a specific type.