Subscribe on changes!

Separate typings for provide | Typescript

avatar
Jul 20th 2022

What problem does this feature solve?

Currently Provide/Inject uses only one key generic to both key and value - provide<T> = (key: InjectionKey<T>, value: T)

My request is to make app.provide<K,T> = (key: InjectionKey<K>, value: T) so that key and value have their own type respectively.

What does the proposed API look like?

avatar
Jul 20th 2022

What would be K, if not the value you provide - which in your API is T?

I don't understand what the goal of this change would be.

avatar
Jul 27th 2022

In my case I wanted K would be string and value T would be Function type. Currently, when I inject the function it doesn't provide typings and show errors that the injected object is type of {}, but I wanted it to be Function

avatar
Jul 27th 2022

Why would you want K to be string?

avatar
Jul 27th 2022

InjectionKey<Function> would give you an injection whose value is Function.

I dont see what problem your proposal is meant to solve.

avatar
Jan 18th 2024

Closing as stale