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...
Post
iirc in typescript object just stands for any non-primitive type, but doesn't convey any information about the object shape itself. though yeah, this case seems annoying you could do `v && 'a' in v && typeof v.a !== 'string'`. that `in` will intersect the object type with `{ a: unknown }`
0 reposts1 like
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)
typescriptlang.orgTS Playground - An online editor for exploring TypeScript and JavaScriptThe Playground lets you write TypeScript or JavaScript online in a safe and sharable way.