const input: unknown = { packets: 8 }; if (typeof input !== "object" || input === null || !("packets" in input)) throw new Error("Missing packets"); const packets = (input as Record)["packets"]; if (typeof packets !== "number" || !Number.isFinite(packets)) throw new Error("Invalid packets"); console.log(packets + 1);