You can't cast it, you have to do ctx.db.normalizeId("table", id)! Not sure what to do about it though - we still want the type hints. maybe allow casting and import Id? 