Hacker News new | ask | show | jobs
by madeofpalk 1368 days ago
You can't actually narrow `unknown` down to a structure yet, as you have no way to test whether `property in unknown` or not.

Well, until this is released! https://github.com/microsoft/TypeScript/pull/50666

1 comments

yeah. You have to assert an object (`Record<string, unknown>`) type first within your asserter (or array or whatever). We ended up having whole stacks of re-usable assertion functions to be used at these boundaries (re-usable on server side too if you're using node!)