Convince me I am wrong: This should not be a type error, right? - I asserted it’s an object - I am using `?.` for property access www.typescriptlang.org/play/#code/G...
0 reposts5 likes
Convince me I am wrong: This should not be a type error, right? - I asserted it’s an object - I am using `?.` for property access www.typescriptlang.org/play/#code/G...
0 reposts5 likes
It's because `object` doesn't have any properties. www.typescriptlang.org/play/#code/G...
alternatively could have `isObject` function that will assert the type of an input to a record with unknown values: www.typescriptlang.org/play/#code/G... looks kinda cleaner, but introduces a whole new function (wonder if minifiers will simply inline it if unexported)
Object check in TS is a PITA. I started parsing them at the edge of the program (app code). This is probably different for lib code. IDK if you're searching for a solution; if so, this is the approach I was using before: www.typescriptlang.org/play/#code/G...