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 }`

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.

0 reposts0 likes