// Copyright (c) 2017 Victorien Elvinger, Matthieu Nicolas // // Licensed under the zlib license (https://opensource.org/licenses/zlib). /** * SafeAny enables to defensively test if an object is valid. * * As an example assume that we receive a well-formed json string. The sender * claims that the json string represents `Person`. The following sample * enables to test its claim: * * ``` * type Person = {fullname: string, birthYear: number} * * const x: SafeAny = JSON.parse(untrustedJson) * if (typeof x === "object" && x !== null && * typeof x.fullname === "string" && typeof x.birthYear === "number") { * * // x is a Person * } * ``` */ export type SafeAny = { [k in keyof T]?: SafeAny } | boolean | number | string | symbol | null | undefined