narrow
The method narrows the variable model doc type. It’s available on Doc.
const ghAccount = account.narrow<GitHubAccount>( (data) => data.type === "github" && data,);//=> Doc<GitHubAccount> | undefinedThe method accepts a function that has to return the data of the target type or undefined.
It allows checking the data structure on the runtime and also asserts the type. If the data structure checks aren’t sufficient, it will result in a type error.