A modular construction of type theories (Logical Methods in Computer Science, 2023)