const a =<T extends unknown>(arg:T)=>arg
const a_ = a(1) // type is 1
const b =<T extends unknown>(arg:T)=>({arg})
const b_= b(1) // type is {arg: number}, expect {arg: 1}
const c =<T extends unknown>(arg:T)=>({arg})
const c_= b(1 as const) // type is {arg: 1}, ok but degrade dev experience
In the example, if I return an object where the member type is based on the generic, it is widen back to number
even if the generic type is 1
problem solved if I give it const assertion, but it is not a good dev experience
How can I stop this widening behaviour?
Note: T must extends unknown