3 ms·
`get` will destroy type inference, there's no workaround. Your output types are always `any`. The new optional chaining fixes that problem, giving you the same
by tomconroy 7y ago
`get` will destroy type inference, there's no workaround. Your output types are always `any`. The new optional chaining fixes that problem, giving you the same terseness as `get`
- fgkramer 7y agohttps://www.npmjs.com/package/typesafe-get https://www.npmjs.com/package/typesafe-get works pretty good
- ssalka 7y agoIn lodash's defense, there is a @types package for it, which has a typed _.get. However, in my experience, the lodash typings are really difficult to use correctly. Definitely will be replacing usage of _.get with optional chaining soon.
- notus 7y agoright but the person I was responding to isn't using typescript, they were just considering it. For a non typescript user lodash get would be fine.