News for hackers. Stuff that matters.
Re:TypeScript 3.7 by notus on Tuesday November 05, 2019 @05:10PM (#21457299)
I just use lodash get when I access object properties
Re:TypeScript 3.7 by tomconroy on Tuesday November 05, 2019 @05:13PM (#21457323)
`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`
Re:TypeScript 3.7 by ssalka on Tuesday November 05, 2019 @05:45PM (#21457586)
In 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.

Re:TypeScript 3.7 by fgkramer on Tuesday November 05, 2019 @05:26PM (#21457441)
Re:TypeScript 3.7 by notus on Wednesday November 06, 2019 @09:02AM (#21462653)
right 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.
Re:TypeScript 3.7 by nerdkid93 on Tuesday November 05, 2019 @05:22PM (#21457418)
TS 3.7 obviates the need for using `lodash.get` or `just-safe-get`, but it does so in a way that preserves the type of your object
Re:TypeScript 3.7 by notus on Wednesday November 06, 2019 @09:03AM (#21462661)
I'm aware :) the person I was responding to is not using typescript