Open pikax opened 1 year ago
I think provide should not accept number
as key.
If we should type convert is acceptable. How about allow bigint, Array of number, Array of int and so on?
@xiaoxiangmoe provide already allows number
but inject does not.
How about allow bigint, Array of number, Array of int and so on?
We should only support PropertyKey
ts type.
Since this is a key for fetching data from an object, I don't think it's a good idea to get/set the same data from the key that is different types but has the same value.
inject(1) === inject('1')
So for TypeScript, I think we'd better disallow the number
type.
We have 2 solutions, either support number or drop number support from provide/inject.
For me either would be alright
I agree with dropping number support.
Vue version
3.3.5
Link to minimal reproduction
https://play.vuejs.org/#eNp9UctOwzAQ/BXLlxYpSlT1VgISoB7gAAg4+hIl2+KS2Ja9CZWi/Du7bpMW8YgUyTszux7v9PLGubRrQa5kHkqvHYoA2LprZXTjrEfRC+dtpytIhIeNGMTG20bMqGc2ae5s4454mnHBI2eXyihzbJ4vErFYXCiTZ4dr6AIqEBpXFwhUCZHHMRmd82wiZCIxlNZs9DbdBWvIaM9iJUtS6xr8k0NtTVByJSLDXFHX9vMhYuhbSEa8fIfy4xd8F/aMKfnsIYDvQMmJw8JvAQ/0+vUR9nSeyMZWbU3qf8gXCLZu2eNBdtuaimyf6aLb+7hKbbZvYb1HMGF8FBtl5RD1StJqeVF/Pf1kd5kuY58yA21xjOVn0v4sa212UOL3lInnn0IIKIpCXB1Vc8qT8FOiXJwSpYod5ZXupoK/vuchwzAJslFxHvvwBbtN3dI=
Steps to reproduce
See
Comp.vue
fileWhat is expected?
Inject to not give typescript error if a number is passed
What is actually happening?
getting the error
System Info
No response
Any additional comments?
provide
seems to acceptnumber
as key, the parameter will be converted to astring
so